From 1e3b1bdeabe65d67769d1d3451672b4f329df492 Mon Sep 17 00:00:00 2001 From: "Dr. Martin Goik" <goik@hdm-stuttgart.de> Date: Mon, 11 May 2020 21:33:20 +0200 Subject: [PATCH] Minor fixes --- Doc/Sd1/statements.xml | 59 +++++++++++++++++++++++++++++------------- Doc/Sda1/xmlschema.xml | 8 +++--- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/Doc/Sd1/statements.xml b/Doc/Sd1/statements.xml index fd6036a1b..2c53c238a 100644 --- a/Doc/Sd1/statements.xml +++ b/Doc/Sd1/statements.xml @@ -1201,9 +1201,10 @@ You entered: 112</screen> </question> <answer> - <programlisting language="java">package start; + <para>Using <code language="java">if</code> conditionals we may + implement:</para> -import java.util.Scanner; + <programlisting language="java">import java.util.Scanner; public class BarOrder { @@ -1214,28 +1215,50 @@ public class BarOrder { final int beverageChoice = scan.nextInt(); // Read user input - switch (beverageChoice) { - case 1: - System.out.print("Tell me your age please:>"); - final int age = scan.nextInt(); - if (age < 16) { - System.out.println("Sorry, we are not allowed to serve beer to underage customers"); - } else { - System.out.println("o.K."); - } - break; - - case 2: + if (1 == beverageChoice) { + System.out.print("Tell me your age please:>"); + final int age = scan.nextInt(); + if (age < 16) { + System.out.println("Sorry, we are not allowed to serve beer to underage customers"); + } else { System.out.println("o.K."); - break; + } + } else if (2 == beverageChoice) { + System.out.println("o.K."); - default: - System.err.println("Sorry, invalid choice"); - break; + } else { + System.err.println("Sorry, invalid choice"); } scan.close(); } }</programlisting> + + <para>With respect to upcoming <code language="java" + linkend="sd1_sect_switch">switch</code> statements a different + approach reads:</para> + + <programlisting language="java">... +final int beverageChoice = scan.nextInt(); // Read user input + +switch (beverageChoice) { + case 1: + System.out.print("Tell me your age please:>"); + final int age = scan.nextInt(); + if (age < 16) { + System.out.println("Sorry, we are not allowed to serve beer to underage customers"); + } else { + System.out.println("o.K."); + } + break; + + case 2: + System.out.println("o.K."); + break; + + default: + System.err.println("Sorry, invalid choice"); + break; +} ...</programlisting> </answer> </qandaentry> </qandadiv> diff --git a/Doc/Sda1/xmlschema.xml b/Doc/Sda1/xmlschema.xml index b59b442dc..1811012fc 100644 --- a/Doc/Sda1/xmlschema.xml +++ b/Doc/Sda1/xmlschema.xml @@ -1228,7 +1228,7 @@ String s1 = new String(), s2 = new String();</programlisting> </figure> <figure xml:id="sda1_xmlschema_fig_organizerAddingTypesInvalid"> - <title>Nested elements becoming invalid</title> + <title>Nested elements now becoming invalid</title> <programlisting language="none"><contact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="organizer.xsd" @@ -1238,7 +1238,7 @@ String s1 = new String(), s2 = new String();</programlisting> <firstName><emphasis role="red">Eve <email>eve@paradise.com</email></emphasis></firstName><co linkends="sda1_xmlschema_fig_organizerAddingTypesInvalid-1" xml:id="sda1_xmlschema_fig_organizerAddingTypesInvalid-1-co"/> - <lastName>Dexter<p>Gordon</p></lastName><co + <lastName><emphasis role="red">Dexter<p>Gordon</p></emphasis></lastName><co linkends="sda1_xmlschema_fig_organizerAddingTypesInvalid-2" xml:id="sda1_xmlschema_fig_organizerAddingTypesInvalid-2-co"/> </contact></programlisting> @@ -1299,7 +1299,7 @@ String s1 = new String(), s2 = new String();</programlisting> <xs:complexType> <emphasis role="red">┃</emphasis> <xs:sequence> ... <emphasis role="red">┃</emphasis> </xs:sequence> <emphasis role="red">┃</emphasis> - <xs:attribute name="birthDate" <emphasis role="red">┃</emphasis> + <xs:attribute name="category" <emphasis role="red">┃</emphasis> type="<emphasis role="red">contactCategoryType</emphasis>" use="optional"/> </xs:complexType> @@ -1312,7 +1312,7 @@ String s1 = new String(), s2 = new String();</programlisting> </tr> <tr> - <th><screen><emphasis>Value 'author' is not + <th><screen><emphasis role="red">Value 'author' is not facet-valid with respect to enumeration' [friend, colleague, -- GitLab