From 27cb8c2457e1e4796562755a43bfe697f6ead89e Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Tue, 25 Jul 2017 16:47:08 +0200
Subject: [PATCH] cosmetics

---
 Doc/Sd1/languageFundamentals.xml |  13 ++-
 Doc/Sd1/objectsClasses.xml       |  18 ++--
 Doc/Sd1/statements.xml           | 150 +++++++++++++++++--------------
 3 files changed, 107 insertions(+), 74 deletions(-)

diff --git a/Doc/Sd1/languageFundamentals.xml b/Doc/Sd1/languageFundamentals.xml
index 0b3787748..00c3b118b 100644
--- a/Doc/Sd1/languageFundamentals.xml
+++ b/Doc/Sd1/languageFundamentals.xml
@@ -18,7 +18,7 @@
       <title>Integer, <xref linkend="glo_ASCII"/> and <xref
       linkend="glo_unicode"/></title>
 
-      <para>We will 9IUD4Gus3PJlFG241X74mainly deal with computation machines.
+      <para>We will deal with computation machines.
       Having just mechanical devices at hand this still works:</para>
 
       <figure xml:id="sd1_fig_cashier">
@@ -842,6 +842,17 @@ System.out.println(10000000000 );  // Compile time error: Integer number too lar
           </tr>
         </informaltable>
       </figure>
+
+      <figure xml:id="sd1_fig_romanNumerals">
+        <title>Just kidding ...</title>
+
+        <programlisting language="java">int year = MMXIV; // <link
+            xlink:href="https://en.wikipedia.org/wiki/Roman_numerals">Roman numerals</link> representation
+
+System.out.println("Olympic winter games: " + year);</programlisting>
+
+        <screen>Olympic winter games: 2014</screen>
+      </figure>
     </section>
 
     <section xml:id="sd1_sect_arithmeticLimitations">
diff --git a/Doc/Sd1/objectsClasses.xml b/Doc/Sd1/objectsClasses.xml
index 910f840f1..7b2245c2e 100644
--- a/Doc/Sd1/objectsClasses.xml
+++ b/Doc/Sd1/objectsClasses.xml
@@ -1589,11 +1589,11 @@ public class Driver {
             </question>
 
             <answer>
-              <para>Depending on your type of Eclipse project (Java,
-              Maven,...) both your <filename>.java</filename> source files and
-              generated <filename>.class</filename> files will be organized
-              below their respective entry level directories. The following is
-              valid for an standard Eclipse Java project:</para>
+              <para>Depending on your type of project (Java, Maven,...) both
+              your <filename>.java</filename> source files and generated
+              <filename>.class</filename> files will be organized below their
+              respective entry level directories. The following is valid for
+              a standard Eclipse Java project:</para>
 
               <glosslist>
                 <glossentry>
@@ -1647,6 +1647,14 @@ public class Driver {
         </qandadiv>
       </qandaset>
     </section>
+
+    <section xml:id="sd1_sect_representPolynomials">
+      <title>Representing polynomials</title>
+
+      <para>Consider a class representing polynomials:</para>
+
+      <programlisting language="java"/>
+    </section>
   </section>
 
   <section xml:id="sd1SectStaticMembers">
diff --git a/Doc/Sd1/statements.xml b/Doc/Sd1/statements.xml
index d70d1cc06..3ac14ae84 100644
--- a/Doc/Sd1/statements.xml
+++ b/Doc/Sd1/statements.xml
@@ -58,31 +58,37 @@
                 </mediaobject>
               </figure>
 
-              <para>A bar uses a software system picking up orders. The bar
-              will serve just orange juice and beer. For legal reasons the
-              latter will only be served to persons who are at least 16 years
-              old. We show three examples of possible user dialogues:</para>
+              <para>A bar uses a software system for picking up orders. The
+              bar will serve just orange juice and beer. For legal reasons the
+              latter will only be served to persons of at least 16 years of
+              age. We show three possible user dialogues:</para>
 
               <orderedlist>
                 <listitem>
-                  <screen>Your order:
+                  <screen>On offer:
   1=Beer
-  2=Orange juice:1
-Tell me your age please:15
+  2=Orange juice
+
+Your choice:&gt;1
+Tell me your age please:&gt;15
 Sorry, we are not allowed to serve beer to underage customers</screen>
                 </listitem>
 
                 <listitem>
-                  <screen>Your order:
+                  <screen>On offer:
   1=Beer
-  2=Orange juice:2
+  2=Orange juice
+
+Your choice:&gt;2
 o.K.</screen>
                 </listitem>
 
                 <listitem>
-                  <screen>Your order:
+                  <screen>On offer:
   1=Beer
-  2=Orange juice:4
+  2=Orange juice
+
+Your choice:&gt;4
 Sorry, invalid choice</screen>
                 </listitem>
               </orderedlist>
@@ -100,7 +106,7 @@ public class BarOrder {
    public static void main(String[] args) {
     
       final Scanner scan = new Scanner(System.in); // Read user input
-      System.out.print("Your order:\n  1=Beer\n  2=Orange juice:");
+        ...
       final int beverageChoice = scan.nextInt();
       
     //TODO: complete me!
@@ -117,33 +123,34 @@ import java.util.Scanner;
 
 public class BarOrder {
 
-   public static void main(String[] args) {
-    
-      final Scanner scan = new Scanner(System.in); // Read user input
-      System.out.print("Your order:\n  1=Beer\n  2=Orange juice:");
-      final int beverageChoice = scan.nextInt();
-      
-      switch (beverageChoice) {
-      case 1:
-         System.out.print("Tell me your age please:");
-         final int age = scan.nextInt();
-         if (age &lt; 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;
-      }
-      scan.close();
-   }
+    public static void main(String[] args) {
+
+        final Scanner scan = new Scanner(System.in);
+        System.out.print("On offer:\n  1=Beer\n  2=Orange juice\n\nYour choice:&gt;" );
+
+        final int beverageChoice = scan.nextInt(); // Read user input
+
+        switch (beverageChoice) {
+            case 1:
+                System.out.print("Tell me your age please:&gt;");
+                final int age = scan.nextInt();
+                if (age &lt; 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;
+        }
+        scan.close();
+    }
 }</programlisting>
             </answer>
           </qandaentry>
@@ -158,24 +165,28 @@ public class BarOrder {
         <qandadiv>
           <qandaentry>
             <question>
-              <para>We want to write an application which allows to tell a
-              user whether a given year is a leap year or not. The following
-              dialogue may serve as an example:</para>
+              <para>We want to write an application telling whether a given
+              year is a leap year or not. The following dialogue may serve as
+              an example:</para>
 
-              <screen>Enter a year:1980
+              <screen>Enter a year:&gt;1980
 Year 1980 is a leap year</screen>
 
+              <screen>Enter a year:&gt;1900
+Year 1900 is no leap year</screen>
+
               <para>You may reuse the user input handling code from the
               previous example <xref linkend="sd1SectAtTheBar"/>.</para>
 
               <tip>
-                <para>Read about the Gregorian Calendar to find the rule
+                <para>Read about the Gregorian Calendar which defines rules
                 governing leap years.</para>
               </tip>
             </question>
 
             <answer>
-              <para>A first solution might read:</para>
+              <para>A first straightforward rule translation based solution
+              reads:</para>
 
               <programlisting language="java">package start;
 
@@ -186,14 +197,15 @@ public class LeapYear {
    public static void main(String[] args) {
     
       final Scanner scan = new Scanner(System.in); // Read user input
-      System.out.print("Enter a year:");
+      System.out.print("Enter a year:&gt;");
       final int year = scan.nextInt();
       scan.close();
 
-      if (year % 400 == 0) {              <emphasis role="bold">// Every 400 years we do have a leap year.</emphasis>
-         System.out.println("Year " + year + " is a leap year");
-       } else if (year % 4 == 0 &amp;&amp;           <emphasis role="bold">// Every 4 years we do have a leap year</emphasis>  
-                  0 != year % 100) {         <emphasis role="bold">// unless year is a multiple of 100.</emphasis>
+      if (0 == year % 400) {                   <emphasis role="bold"> // Every 400 years we do have a leap year.</emphasis>
+         System.out.println(
+          "Year " + year + " is a leap year");
+       } else if (0 == year % 4 &amp;&amp;          <emphasis role="bold">    // Every 4 years we do have a leap year</emphasis>  
+                  0 != year % 100) {         <emphasis role="bold">   // unless year is a multiple of 100.</emphasis>
           System.out.println("Year " + year + " is a leap year");  
        } else {
           System.out.println("Year " + year + " is no leap year");
@@ -201,20 +213,20 @@ public class LeapYear {
    }
 }</programlisting>
 
-              <para>This solution contains two print statements producing
-              identical output. We may resolve this redundancy by collapsing
-              the first two conditional <code>if</code> branches into one
-              resulting in a more compact solution:</para>
+              <para>This solution contains two identical print statements.
+              Developers don't favour redundancies. Combining the first two
+              <code>if</code> branches into one resolves the issue:</para>
 
               <programlisting language="java">   public static void main(String[] args) {
     
       final Scanner scan = new Scanner(System.in); // Read user input
-      System.out.print("Enter a year:");
+      System.out.print("Enter a year:&gt;");
       final int year = scan.nextInt();
       scan.close();
 
-      if (year % 400 == 0 ||                
-          (year % 4 == 0 &amp;&amp;  0 != year % 100)) {
+      if (0 == year % 400 ||              <emphasis role="bold">// Every 400 years we do have a leap year.</emphasis>
+          (0 == year % 4 &amp;&amp;               <emphasis role="bold">// Every 4 years we do have a leap year</emphasis>  
+           0 != year % 100)) {            <emphasis role="bold">// unless year is a multiple of 100.</emphasis>
          System.out.println("Year " + year + " is a leap year");
        } else {
           System.out.println("Year " + year + " is no leap year");
@@ -234,15 +246,17 @@ public class LeapYear {
           <qandaentry>
             <question>
               <para>Write an application which turns a positive integer values
-              up to and including 10 into roman numeral representation:</para>
+              up to and including 10 into <link
+              xlink:href="https://en.wikipedia.org/wiki/Roman_numerals">Roman
+              numeral</link> representation:</para>
 
-              <screen>Enter a number:9
+              <screen>Enter a number:&gt;9
 IX</screen>
 
               <para>If the user enters a value greater than ten the following
               output is to be expected:</para>
 
-              <screen>Enter a number:14
+              <screen>Enter a number:&gt;14
 Decimal value 14 not yet implemented</screen>
             </question>
 
@@ -250,7 +264,7 @@ Decimal value 14 not yet implemented</screen>
               <para><programlisting language="java">   public static void main(String[] args) {
     
       final Scanner scan = new Scanner(System.in); // Read user input
-      System.out.print("Enter a number:");
+      System.out.print("Enter a number:&gt;");
       final int number = scan.nextInt();
       scan.close();
 
@@ -3184,7 +3198,7 @@ import java.util.Random;
               then c has to be decremented by 1 as well.</para>
 
               <para>For convenience reasons we introduce a variable <code>int
-              sum = 840</code> representing our sum of all three valuesOur
+              sum = 840</code> representing our sum of all three values. Our
               filter condition now only needs to check for the remaining
               Pythagorean condition <inlineequation>
                   <m:math display="inline">
@@ -3525,9 +3539,9 @@ for (int a = 1; a &lt;= sum / 3; a++) {
                       </m:mrow>
                     </m:mrow>
                   </m:math>
-                </inlineequation>.The <quote>remainder of modulus
-              operator</quote> <code>%</code> testing for a zero remainder
-              helps us finding the desired triples:</para>
+                </inlineequation>.The <quote>remainder of modulus</quote>
+              operator <code>%</code> testing for a zero remainder filters the
+              desired triples:</para>
 
               <programlisting language="java">final int sum = 840;
 
@@ -3543,9 +3557,9 @@ for (int a = 1; a &lt;= sum / 3; a++) {
   }
 }</programlisting>
 
-              <para>This yields the same result but execution is (again) ways
-              faster. This will pay off when looking for larger values of
-              <code>sum</code>.</para>
+              <para>This yields the same result as before but execution is
+              (again) ways faster. This will pay off when looking for larger
+              values of <code>sum</code>.</para>
             </answer>
           </qandaentry>
         </qandadiv>
-- 
GitLab