From 9a979418226b99f60289af8f41e9ba60ca7f52a5 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Tue, 15 Sep 2015 22:06:45 +0200 Subject: [PATCH] Re-introducing language attribute --- Doc/Makefile | 3 +- Doc/Sd1/arrays.xml | 20 +++++------ Doc/Sd1/coreClasses.xml | 40 +++++++++++----------- Doc/Sd1/inheritance.xml | 6 ++-- Doc/Sd1/interfacesAbstractClasses.xml | 12 +++---- Doc/Sd1/languageFundamentals.xml | 6 ++-- Doc/Sd1/objectsClasses.xml | 42 +++++++++++------------ Doc/Sd1/statements.xml | 48 +++++++++++++-------------- Doc/Sd1/streams.xml | 2 +- 9 files changed, 89 insertions(+), 90 deletions(-) diff --git a/Doc/Makefile b/Doc/Makefile index 0b79293b5..e84997098 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -12,7 +12,7 @@ PPARAM= -p eclipse.plugin.name Lectures \ DOCMODULES=Sd1 Sda1 Sda2 #DOCMODULES=Sda2 -BUILDROOT=/tmp +BUILDROOT=target #+++ no changes below this line ++++++++++++++++++++++++++++++++++++ @@ -31,7 +31,6 @@ SAXONCMD=java -cp "/usr/share/java/Saxon-HE.jar:/usr/share/java/xercesImpl.jar" # # Dependent destinations # -BUILDROOT=target BUILDBASE=$(BUILDROOT)/$(SCRIPTBASENAME) BUILDNAVI=navi/$(PLUGINID) BUILDNONAVI=nonavi/$(PLUGINID) diff --git a/Doc/Sd1/arrays.xml b/Doc/Sd1/arrays.xml index c080cc17c..0cd64be04 100644 --- a/Doc/Sd1/arrays.xml +++ b/Doc/Sd1/arrays.xml @@ -19,7 +19,7 @@ <para>Consider an array of strings. As an example we provide a list of country names:</para> - <programlisting language="none">final String[] countries = { + <programlisting language="java">final String[] countries = { "England" ,"France" ,"Germany" @@ -28,7 +28,7 @@ <para>An application is supposed to generate the following output:</para> - <programlisting language="none"><ul> + <programlisting language="xml"><ul> <li>England</li> <li>France</li> <li>Germany</li> @@ -37,7 +37,7 @@ <para>Implement A class method <methodname>strings2html(final String [] strings)</methodname> as in:</para> - <programlisting language="none">public class Stringarray2Html { + <programlisting language="java">public class Stringarray2Html { /** * Create an unordered ... @@ -162,7 +162,7 @@ <para>Each leg may have a different speed limit. We thus define:</para> - <programlisting language="none">public class Segment { + <programlisting language="java">public class Segment { /** * Indication a segment does not have any speed limit. @@ -193,7 +193,7 @@ <para>A given route will be defined by an array of segments:</para> - <programlisting language="none"> final Segment[] route = new Segment[] { + <programlisting language="java"> final Segment[] route = new Segment[] { new Segment(2.4, 50) ,new Segment(5, 100) ,new Segment(3.1, 50) @@ -204,7 +204,7 @@ which allows for calculation of minimum time required with respect to speed limits to travel a given route.</para> - <programlisting language="none"> /** + <programlisting language="java"> /** * Minimal time required when consequently traveling with the minimum of * official speed limits and the driver's personal maximum speed. If a * leg does not have any speed limit the value of personalSpeedLimit will @@ -230,7 +230,7 @@ <para>You may want to start implementing a main() method example first to gain some experience:</para> - <programlisting language="none">public class Driver { + <programlisting language="java">public class Driver { /** * @param args unused */ @@ -684,7 +684,7 @@ public class Driver { <para>Testing for equality of two <code>double</code> variables is generally a bad idea. Consider:</para> - <programlisting language="none">double b= 1./3.; + <programlisting language="java">double b= 1./3.; b++; b--; System.out.println(3 * b);</programlisting> @@ -700,7 +700,7 @@ System.out.println(3 * b);</programlisting> expected, double actual, double delta)</code> addressing this problem:</para> - <programlisting language="none">@Test + <programlisting language="java">@Test public void testApp() { double b= 1./3.; @@ -1447,7 +1447,7 @@ values newArray | 1| 2| F| 7| 9| | ...</programlisting> plot function is hard coded within the <classname>PlotSine</classname> class:</para> - <programlisting language="none"> static void plotSine() { + <programlisting language="java"> static void plotSine() { init(); for (int xTics = 0; xTics < numTicsX; xTics++) { diff --git a/Doc/Sd1/coreClasses.xml b/Doc/Sd1/coreClasses.xml index e5fb22632..8732454ca 100644 --- a/Doc/Sd1/coreClasses.xml +++ b/Doc/Sd1/coreClasses.xml @@ -23,7 +23,7 @@ linkend="sd1SectIntermediateMultiplication"/> and other exercises. Consider the following snippet:</para> - <programlisting language="none"> int value = 33; + <programlisting language="java"> int value = 33; double secondValue = 114.317; System.out.format("Just a single integer %3d\n", value); @@ -80,7 +80,7 @@ <para>Consider the following snippet:</para> - <programlisting language="none"> final int v = 33; + <programlisting language="java"> final int v = 33; final double d = 114.317; final short color = 255; @@ -93,7 +93,7 @@ <para>We may prettify our code to better reflect the one to one correspondence between format strings and variables:</para> - <programlisting language="none"> System.out.format("v=%d, d=%5.2f, color=%2x\n", + <programlisting language="java"> System.out.format("v=%d, d=%5.2f, color=%2x\n", v, d, color);</programlisting> <caution> @@ -101,7 +101,7 @@ having appropriate types likely results in a runtime exception:</para> - <programlisting language="none"> System.out.format("v=%d, d=%d, color=%2x\n", // Error: Using %s rather than %f + <programlisting language="java"> System.out.format("v=%d, d=%d, color=%2x\n", // Error: Using %s rather than %f v, d, color);</programlisting> <programlisting language="none">v=33, d=Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double @@ -135,7 +135,7 @@ accidental redefinition using the <code>final</code> modifier:</para> - <programlisting language="none">public static void main(String[] args) { + <programlisting language="java">public static void main(String[] args) { double radius = 2.31; // A square having a radius (given e.g. in mm). final double pi = 3.1415926; // Creating pi as a constant (non-modifiable/assignable) variable. @@ -167,7 +167,7 @@ <answer> <para>The short answer simply is:</para> - <programlisting language="none" linenumbering="numbered">public static void main(String[] args) { + <programlisting language="java" linenumbering="numbered">public static void main(String[] args) { double radius = 2.31; // A square having a radius (given e.g. in mm). @@ -183,7 +183,7 @@ xlink:href="http://proquest.safaribooksonline.com/9780992133047/toc13_html">static import</link> statement:</para> - <programlisting language="none" linenumbering="numbered"><emphasis + <programlisting language="java" linenumbering="numbered"><emphasis role="bold">import static java.lang.Math.PI;</emphasis> public class CircleAreaCalculator { @@ -203,7 +203,7 @@ public class CircleAreaCalculator { browsing its implementation <filename>Math.java</filename> reveals:</para> - <programlisting language="none">/* + <programlisting language="java">/* * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. * ... */ @@ -230,7 +230,7 @@ public final class Math { xlink:href="http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html">Math</classname> class:</para> - <programlisting language="none">import java.lang.<emphasis + <programlisting language="java">import java.lang.<emphasis role="bold">Math</emphasis>; // Optional: Classes from java.lang are imported // implicitely as per the Java language specification. @@ -334,7 +334,7 @@ public class CircleAreaCalculator { You may favor decomposing it to a set of smaller string literals:</para> - <programlisting language="none">final String input = "731671765 ... 94934" + <programlisting language="java">final String input = "731671765 ... 94934" + ... + "716362695 ... 63450";</programlisting> </listitem> @@ -373,7 +373,7 @@ public class CircleAreaCalculator { substring(...)</methodname> allows for accessing the set of all substrings of 13 adjacent digits:</para> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { final String input = "73167176531330624919225119674426574742355349194934" @@ -424,7 +424,7 @@ public class CircleAreaCalculator { character '4' equals its ASCII value which is just 52. Thus we need a translation like:</para> - <programlisting language="none"> private static int getDigitValue (final char digit) { + <programlisting language="java"> private static int getDigitValue (final char digit) { switch(digit) { case '0': return 0; case '1': return 1; @@ -447,7 +447,7 @@ public class CircleAreaCalculator { represent digits by 10 successive integer values we may as well choose the following implementation:</para> - <programlisting language="none"> private static int getDigitValue (final char digit) { + <programlisting language="java"> private static int getDigitValue (final char digit) { switch(digit) { case '0': return 0; case '1': return 1; @@ -471,7 +471,7 @@ public class CircleAreaCalculator { are looking for 7 × 3 ×1 × 6 ×7 × 1 ×7 × 6 × 5 × 3 × 1 × 3 × 3 = 5000940. We define:</para> - <programlisting language="none"> private static int getDigitProduct(final String digitWord) { + <programlisting language="java"> private static int getDigitProduct(final String digitWord) { int product = 1; for (int i = 0; i < digitWord.length(); i++) { product *= getDigitValue(digitWord.charAt(i)); @@ -497,7 +497,7 @@ public class CircleAreaCalculator { 9 × 9 × 9 = 2,541,865,828,329 value. We thus change our data type from <code>int</code> to <code>long</code>:</para> - <programlisting language="none"> private static <emphasis + <programlisting language="java"> private static <emphasis role="bold">long</emphasis> getDigitProduct(final String digitWord) { <emphasis role="bold">long</emphasis> product = 1; for (int i = 0; i < digitWord.length(); i++) { @@ -509,7 +509,7 @@ public class CircleAreaCalculator { <para>Putting these pieces together leaves us with the following <code>main(...)</code> method:</para> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { String input = "73167176531330624919225119674426574742355349194934" + "96983520312774506326239578318016984801869478851843" @@ -604,7 +604,7 @@ public class CircleAreaCalculator { <answer> <para>Execution yields:</para> - <programlisting language="none">a1 == a2: true <co + <programlisting language="java">a1 == a2: true <co linkends="answerCoStringOperatorEquality-1" xml:id="answerCoStringOperatorEquality-1-co"/> a1.equals(a2): true @@ -791,7 +791,7 @@ b1.equals(b2): true </programlisting> corresponding to the previously described values. Consider the following usage example:</para> - <programlisting language="none">public class WindowsExample { + <programlisting language="java">public class WindowsExample { /** * @param args Unused @@ -944,7 +944,7 @@ File extension: html</programlisting> platforms. The following tests may be used as a starting point:</para> - <programlisting language="none">public class MetaInfoUnixTest { + <programlisting language="java">public class MetaInfoUnixTest { static private final boolean isWindows = System.getProperty("os.name").startsWith("Windows"); @@ -1001,7 +1001,7 @@ File extension: html</programlisting> } }</programlisting> - <programlisting language="none">public class MetaInfoWindowsTest { + <programlisting language="java">public class MetaInfoWindowsTest { static private final boolean isWindows = System.getProperty("os.name").startsWith("Windows"); diff --git a/Doc/Sd1/inheritance.xml b/Doc/Sd1/inheritance.xml index 729829010..047d6e7fb 100644 --- a/Doc/Sd1/inheritance.xml +++ b/Doc/Sd1/inheritance.xml @@ -87,7 +87,7 @@ instance of class <classname>Figure allows for operation chaining:</classname></para> - <programlisting language="none">final Circle c = new Circle(1., 2., 3.0); + <programlisting language="java">final Circle c = new Circle(1., 2., 3.0); c.move(1, 5).move(-3, 7);</programlisting> </answer> </qandaentry> @@ -131,7 +131,7 @@ c.move(1, 5).move(-3, 7);</programlisting> defining an abstract method in <classname>our class Figure</classname>: </para> - <programlisting language="none">/** + <programlisting language="java">/** * * @param factor Scale the current figure by this value. * @return The current object. @@ -173,7 +173,7 @@ c.move(1, 5).move(-3, 7);</programlisting> <question> <para>Consider:</para> - <programlisting language="none"> final Circle c = new Circle(-2, -1, 3.5); + <programlisting language="java"> final Circle c = new Circle(-2, -1, 3.5); final Rectangle r = new Rectangle(3, 1, 1.5, 4.4); System.out.println(c); diff --git a/Doc/Sd1/interfacesAbstractClasses.xml b/Doc/Sd1/interfacesAbstractClasses.xml index e5eebe187..aa896cfeb 100644 --- a/Doc/Sd1/interfacesAbstractClasses.xml +++ b/Doc/Sd1/interfacesAbstractClasses.xml @@ -20,7 +20,7 @@ xlink:href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html">String</classname> array definitions:</para> - <programlisting language="none"> private static final String[] ADJECTIVES = { + <programlisting language="java"> private static final String[] ADJECTIVES = { "red", "green", "yellow", "gray", "solid", // Index 4 "fierce", "friendly", "cowardly", "convenient", "foreign", // Index 9 "national", "tall", "short", "metallic", "golden", // Index 14 @@ -82,7 +82,7 @@ The nationwide potato buys a monitor.</programlisting> your random generator by a (predictive) sequence generator:</para> - <programlisting language="none">@Test + <programlisting language="java">@Test public void testApp() { final NonsenseGenerator nonsenseGenerator = new NonsenseGenerator( new PredictableSequenceGenerator(new int[]{ @@ -125,7 +125,7 @@ public void testApp() { from the desired plotting function. The idea is defining a corresponding interface:</para> - <programlisting language="none">public interface DoubleOfDouble { + <programlisting language="java">public interface DoubleOfDouble { /** * A function expecting a double argument and returning * a double value like e.g. double Math.sin(double) @@ -140,7 +140,7 @@ public void testApp() { Plotting e.g. <function>y=sin(x)</function> will then be effected by:</para> - <programlisting language="none">class MySin implements DoubleOfDoubleFunction { + <programlisting language="java">class MySin implements DoubleOfDoubleFunction { @Override public double compute(double x) { @@ -150,7 +150,7 @@ public void testApp() { <para>Plotting will then require an instance:</para> - <programlisting language="none">final DoubleOfDoubleFunction sinFunction = new MySin(); + <programlisting language="java">final DoubleOfDoubleFunction sinFunction = new MySin(); plotter.plot(sinFunction);</programlisting> </question> @@ -171,7 +171,7 @@ plotter.plot(sinFunction);</programlisting> respect to upcoming topics in <quote xml:lang="de">Softwareentwicklung 2</quote>:</para> - <programlisting language="none">public class DriverLambda { + <programlisting language="java">public class DriverLambda { /** * @param args Unused diff --git a/Doc/Sd1/languageFundamentals.xml b/Doc/Sd1/languageFundamentals.xml index f932dcde3..f57d3f5c6 100644 --- a/Doc/Sd1/languageFundamentals.xml +++ b/Doc/Sd1/languageFundamentals.xml @@ -815,7 +815,7 @@ System.out.println("Maximum short value:" + maximum); xlink:href="https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html">Integer</classname> classes. You may want to execute:</para> - <programlisting language="none"> System.out.println("int minimum:" + Integer.MIN_VALUE); + <programlisting language="java"> System.out.println("int minimum:" + Integer.MIN_VALUE); System.out.println("int minimum:" + Integer.MAX_VALUE); System.out.println("int bytes:" + Integer.BYTES); @@ -1258,7 +1258,7 @@ System.out.println("New value=" + a);</programlisting> <quote>+</quote> operator in Java always returning an <code>int</code> rather than a byte. Consider:</para> - <programlisting language="none"> byte a = 120, b = 10; + <programlisting language="java"> byte a = 120, b = 10; System.out.println(a + b);</programlisting> <para>This yields the expected output of 130 and corresponds to @@ -1268,7 +1268,7 @@ System.out.println("New value=" + a);</programlisting> <code>byte</code> an arithmetic overflow as in the subsequent code example would occur:</para> - <programlisting language="none"> byte a = 120, b = 10; + <programlisting language="java"> byte a = 120, b = 10; byte sum = (byte) (a + b); diff --git a/Doc/Sd1/objectsClasses.xml b/Doc/Sd1/objectsClasses.xml index c71c1118f..f980b4d98 100644 --- a/Doc/Sd1/objectsClasses.xml +++ b/Doc/Sd1/objectsClasses.xml @@ -165,7 +165,7 @@ <itemizedlist> <listitem> - <programlisting language="none"> /** + <programlisting language="java"> /** * Raise the employee's salary by the given percentage. * * Example: If the current annual salary is 30000 € then @@ -180,7 +180,7 @@ </listitem> <listitem> - <programlisting language="none"> /** + <programlisting language="java"> /** * Print the employee's current state to standard output like e.g.: * * <pre>Age:25 @@ -195,7 +195,7 @@ Salary:30000.00</pre> <para>Run your implementation by a separate class <code>Driver</code>:</para> - <programlisting language="none">package company; + <programlisting language="java">package company; public class Driver { @@ -221,7 +221,7 @@ Salary:30600.00</programlisting> </question> <answer> - <programlisting language="none"> /** + <programlisting language="java"> /** * Raise the employee's salary by the given percentage. * * Example: If the current annual salary is 30000 € then @@ -261,7 +261,7 @@ Salary:30000.00</pre> <para>Currently our constructor is being implemented as:</para> - <programlisting language="none"> public Employee(int ageValue, double salaryValue) { + <programlisting language="java"> public Employee(int ageValue, double salaryValue) { age = ageValue; salary = salaryValue; }</programlisting> @@ -276,7 +276,7 @@ Salary:30000.00</pre> shadowing of variable names. From the viewpoint of mere code comprehensibility we prefer:</para> - <programlisting language="none"> public Employee(int age, double salary) { + <programlisting language="java"> public Employee(int age, double salary) { age = age; // Compiler warning: The assignment to variable age has no effect salary = salary; // Compiler warning: The assignment to variable salary has no effect }</programlisting> @@ -303,7 +303,7 @@ Salary:30000.00</pre> <glossterm>Class scope:</glossterm> <glossdef> - <programlisting language="none">public class Employee { + <programlisting language="java">public class Employee { public int <emphasis role="bold">age</emphasis>; public double <emphasis role="bold">salary</emphasis>; ... @@ -316,7 +316,7 @@ Salary:30000.00</pre> scope:</glossterm> <glossdef> - <programlisting language="none">public Employee(int <emphasis + <programlisting language="java">public Employee(int <emphasis role="bold">age</emphasis>, double <emphasis role="bold">salary</emphasis>) {.../* Constructor's method body */}</programlisting> </glossdef> @@ -335,7 +335,7 @@ Salary:30000.00</pre> <code>salary</code> with their respective scope being represented by the <code>this</code> keyword:</para> - <programlisting language="none"> public Employee(int age, double salary) { + <programlisting language="java"> public Employee(int age, double salary) { // The "this" keyword refers to class scope this.age = age; this.salary = salary; @@ -982,7 +982,7 @@ public void writeSvg() { (<code>public</code> / <code>private</code> / <code>protected</code>):</para> - <programlisting language="none">package company; + <programlisting language="java">package company; public class Employee { int age; @@ -992,7 +992,7 @@ public class Employee { <para>Does the following code work?</para> - <programlisting language="none">package company; + <programlisting language="java">package company; public class Driver { @@ -1052,7 +1052,7 @@ public class Driver { <colgroup width="45%"/> <tr> - <td><programlisting language="none"><emphasis role="bold">package company;</emphasis> + <td><programlisting language="java"><emphasis role="bold">package company;</emphasis> public class Employee { int age; @@ -1061,7 +1061,7 @@ public class Employee { <td align="center">⟹</td> - <td><programlisting language="none"><emphasis role="bold">package model;</emphasis> + <td><programlisting language="java"><emphasis role="bold">package model;</emphasis> public class Employee { int age; @@ -1084,7 +1084,7 @@ public class Employee { <colgroup width="45%"/> <tr> - <td valign="top"><programlisting language="none">package company; + <td valign="top"><programlisting language="java">package company; public class Driver { @@ -1093,7 +1093,7 @@ public class Driver { <td align="center">⟹</td> - <td valign="top"><programlisting language="none">package company; + <td valign="top"><programlisting language="java">package company; <emphasis role="bold">import model.Employee;</emphasis> @@ -1108,7 +1108,7 @@ public class Driver { still residing in our <package>company</package> package will no longer compile:</para> - <programlisting language="none">package company; + <programlisting language="java">package company; public class Driver { @@ -1148,7 +1148,7 @@ public class Driver { xlink:href="http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)">principle of encapsulation</link>:</para> - <programlisting language="none">public class Employee { + <programlisting language="java">public class Employee { <emphasis role="bold">public</emphasis> int age; <emphasis role="bold">public</emphasis> double salary; ...</programlisting> @@ -1169,7 +1169,7 @@ public class Driver { <colgroup width="45%"/> <tr> - <td valign="top"><programlisting language="none">package model; + <td valign="top"><programlisting language="java">package model; public class Employee { int age; @@ -1182,7 +1182,7 @@ public class Employee { <td align="center">⟹</td> - <td valign="top"><programlisting language="none">package company; + <td valign="top"><programlisting language="java">package company; import model.Employee; @@ -2309,7 +2309,7 @@ long sum = (long)a + b;</programlisting> <para>Defining <xref linkend="sd1QandaGcd"/> as a dependency <coref linkend="mvnGcdDep"/> in your current project:</para> - <programlisting language="none"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + <programlisting language="xml"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -4532,7 +4532,7 @@ sin(4 * PI)=4518.2187229323445, difference=4518.2187229323445</programlisting> <para>Do not forget to define suitable unit tests like:</para> - <programlisting language="none">package ... + <programlisting language="java">package ... import org.junit.Assert; import org.junit.Test; diff --git a/Doc/Sd1/statements.xml b/Doc/Sd1/statements.xml index cb81eabc2..8bdddebba 100644 --- a/Doc/Sd1/statements.xml +++ b/Doc/Sd1/statements.xml @@ -73,7 +73,7 @@ Sorry, invalid choice</programlisting> linkend="glo_Java"/> applications to ask for user input simply use the following recipe to get started:</para> - <programlisting language="none">package start; + <programlisting language="java">package start; import java.util.Scanner; @@ -108,7 +108,7 @@ public class BarOrder { </question> <answer> - <programlisting language="none">package start; + <programlisting language="java">package start; import java.util.Scanner; @@ -166,7 +166,7 @@ Year 1980 is a leap year</programlisting> linkend="glo_Java"/> applications to ask for user input simply use the following recipe to get started:</para> - <programlisting language="none">package start; + <programlisting language="java">package start; import java.util.Scanner; @@ -193,7 +193,7 @@ public class LeapYear { <answer> <para>A first solution might read:</para> - <programlisting language="none">package start; + <programlisting language="java">package start; import java.util.Scanner; @@ -221,7 +221,7 @@ public class LeapYear { the first two conditional <code>if</code> branches into one resulting in a more compact solution:</para> - <programlisting language="none"> public static void main(String[] args) { + <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:"); @@ -262,7 +262,7 @@ Decimal value 14 not yet implemented</programlisting> </question> <answer> - <para><programlisting language="none"> public static void main(String[] args) { + <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:"); @@ -304,7 +304,7 @@ Decimal value 14 not yet implemented</programlisting> from the <quote>Statements</quote> section of <xref linkend="bib_Kurniawan2015"/>:</para> - <programlisting language="none"> final int limit = 14; + <programlisting language="java"> final int limit = 14; for (int i = 0; i < limit; i++) { if (i % 2 == 0) { @@ -328,7 +328,7 @@ Decimal value 14 not yet implemented</programlisting> </question> <answer> - <programlisting language="none"> final int limit = 14; + <programlisting language="java"> final int limit = 14; for (int i = 0; i < limit; i += 2) { System.out.println(i); @@ -373,7 +373,7 @@ Decimal value 14 not yet implemented</programlisting> <colgroup width="48%"/> <tr> - <td valign="top"><programlisting language="none"> public static void main(String[] args) { + <td valign="top"><programlisting language="java"> public static void main(String[] args) { int numberOfRows = 7; @@ -491,7 +491,7 @@ Decimal value 14 not yet implemented</programlisting> <para>We start by a version being fully covered by our knowledge gained so far:</para> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { // Example: 5 row groups, tree's body loop index ranging from 0 to 4 @@ -576,7 +576,7 @@ Decimal value 14 not yet implemented</programlisting> <para>This effectively makes our code more readable:</para> - <programlisting language="none">public class XmasTree { + <programlisting language="java">public class XmasTree { private static void printIndented(int indentation, String s) { if (0 < indentation) { @@ -683,7 +683,7 @@ Decimal value 14 not yet implemented</programlisting> statements to print the table's head and a loop for printing the body:</para> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { System.out.println("n | n * n"); // Printing the table's head System.out.println("--+------"); @@ -765,7 +765,7 @@ Decimal value 14 not yet implemented</programlisting> xlink:href="https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#out">System.out</link>.<link xlink:href="https://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html#format-java.lang.String-java.lang.Object...-">format</link>(...)</methodname>:</para> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { final int limit = 20; // The number of records to be printed @@ -795,7 +795,7 @@ Decimal value 14 not yet implemented</programlisting> <para>Modify the previous code to generate HTML output instead of pure text and watch the result in a WEB browser:</para> - <programlisting language="none"><html xmlns='http://www.w3.org/1999/xhtml'> + <programlisting language="xml"><html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>A square table</title> </head> @@ -820,7 +820,7 @@ Decimal value 14 not yet implemented</programlisting> </question> <answer> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { final int limit = 20; // The number of records to be printed @@ -898,7 +898,7 @@ Decimal value 14 not yet implemented</programlisting> <para>You'll need a loop nested within an outer one like:</para> - <programlisting language="none">for (int y=0; < limit; y++){ + <programlisting language="java">for (int y=0; < limit; y++){ for (int x=0; x < limit; x++) { ... @@ -908,7 +908,7 @@ Decimal value 14 not yet implemented</programlisting> </question> <answer> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { int limit = 10; @@ -980,7 +980,7 @@ Decimal value 14 not yet implemented</programlisting> exercise is very small. We need a limit <code>col = row</code> rather than <code>col = 1</code>:</para> - <programlisting language="none"> for (int row = 1; row <= limit; row ++) { // Printing rows + <programlisting language="java"> for (int row = 1; row <= limit; row ++) { // Printing rows System.out.format("%3d| ", row); for (int <emphasis role="bold">col = row;</emphasis> col <= limit; col++) { // Printing columns System.out.format("%3d ", row * col); @@ -1054,7 +1054,7 @@ Decimal value 14 not yet implemented</programlisting> </question> <answer> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { final int numBlocksHorizontal = 5, numBlocksVertical = 2, @@ -1127,11 +1127,11 @@ Decimal value 14 not yet implemented</programlisting> <xref linkend="glo_Java"/> code since it does not interfere with string literal delimiters:</para> - <programlisting language="none">System.out.print("<col span='2'/>\n");</programlisting> + <programlisting language="java">System.out.print("<col span='2'/>\n");</programlisting> <para>rather than the more clumsy:</para> - <programlisting language="none">System.out.print("<col span=\"2\"/>\n");</programlisting> + <programlisting language="java">System.out.print("<col span=\"2\"/>\n");</programlisting> </tip> </question> @@ -1141,7 +1141,7 @@ Decimal value 14 not yet implemented</programlisting> are subsequently being referenced from the document's body.</para> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { final int numBlocksHorizontal = 5, numBlocksVertical = 2, @@ -1257,7 +1257,7 @@ Congratulations! you won!</programlisting> <para>Regarding user input reading and random number generating methods please use the following recipe to get started:</para> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { final short maxValueInclusive = 10; // Upper inclusive limit for selecting random numbers. @@ -1275,7 +1275,7 @@ Congratulations! you won!</programlisting> </question> <answer> - <programlisting language="none"> public static void main(String[] args) { + <programlisting language="java"> public static void main(String[] args) { final int maxValueInclusive = 10, numOfUserAttempts = 5, diff --git a/Doc/Sd1/streams.xml b/Doc/Sd1/streams.xml index 0da0691c2..653070dc7 100644 --- a/Doc/Sd1/streams.xml +++ b/Doc/Sd1/streams.xml @@ -54,7 +54,7 @@ <para>Your application shall add line numbers:</para> - <programlisting language="none">1: <html> + <programlisting language="xml">1: <html> 2: <head> 3: <title>A simple HTML example</title> 4: </head> -- GitLab