diff --git a/Doc/Sd1/objectsClasses.xml b/Doc/Sd1/objectsClasses.xml index 3b6387a4ab003686a5f3f1d407c22b8cb4ce056c..c98d47ec318662980d260cdab58821668aaf7ca3 100644 --- a/Doc/Sd1/objectsClasses.xml +++ b/Doc/Sd1/objectsClasses.xml @@ -522,13 +522,13 @@ public class Print { <programlisting language="java">public static void main(...) { String john = new String("John"); - System.out.println("Name:" + john); + System.out.println("Name: " + john); System.out.println(john.sayHello()); }</programlisting> <para>The expected output reads:</para> - <screen>John + <screen>Name: John Hello 'John'</screen> <tip> @@ -1023,7 +1023,7 @@ public class Rectangle { } /** - * @param width The rectangle's new height + * @param height The rectangle's new height */ public void setHeight(double height) { // TODO @@ -1368,7 +1368,7 @@ public class Circle { // TODO } /** - * @param x The circle's x center coordinate value + * @param y The circle's y center coordinate value */ public void setY(double y) { // TODO @@ -1404,7 +1404,7 @@ public class Circle { * * @param x The circle center's x-coordinate * @param y The circle center's y-coordinate - * @param The circle's radius + * @param radius The circle's radius */ public Circle(double x, double y, double radius) { ... @@ -1456,7 +1456,7 @@ public class Circle { r.writeSvg(); // Draw a circle as SVG - final Circle c = new Circle(1, 3); + final Circle c = new Circle(3); c.setX(3); c.setY(1); c.writeSvg(); @@ -1468,8 +1468,12 @@ public class Circle { <para>Implement the method <methodname>void writeSvg()</methodname> in both classes <classname>Rectangle</classname> and - <classname>Circle</classname>. This should produce an output - result like:</para> + <classname>Circle</classname>. The following sample export is + intended for 300x200 pixel requiring to scale + <abbrev>e.g.</abbrev> the above circle's radius of three by a + factor of 20 resulting in an effective <tag + class="emptytag">circle r='60' ...</tag> value. This scaling is + being required for all parameters:</para> <programlisting language="java"><!DOCTYPE html> <html> @@ -2595,6 +2599,63 @@ a = 33;</programlisting></td> </informaltable> </figure> + <figure xml:id="sd1_fig_rectangle_constructorCallsConstructor"> + <title>Constructor calls within constructor</title> + + <informaltable border="1"> + <tr> + <td valign="top"><programlisting language="java">public class Rectangle { + int width, height; + + public Rectangle(int width, int height){ + this.width = width; + this.height = height; + } + public Rectangle() { + width = height = 1; + } + public Rectangle(int widthAndHeight) { + width = height = widthAndHeight; + } +}</programlisting></td> + + <td><programlisting language="java">public class Rectangle { + int width, height; + + public Rectangle(int width, int height){ + this.width = width; + this.height = height; + } + public Rectangle() { + this(1, 1); <co linkends="sd1_fig_rectangle_constructorCallsConstructor-1" + xml:id="sd1_fig_rectangle_constructorCallsConstructor-1-co"/> + } + public Rectangle(int widthAndHeight) { + this(widthAndHeight, widthAndHeight); <co + linkends="sd1_fig_rectangle_constructorCallsConstructor-2" + xml:id="sd1_fig_rectangle_constructorCallsConstructor-2-co"/> + } +}</programlisting></td> + </tr> + </informaltable> + </figure> + + <calloutlist> + <callout arearefs="sd1_fig_rectangle_constructorCallsConstructor-1-co" + xml:id="sd1_fig_rectangle_constructorCallsConstructor-1"> + <para>Reusing constructor <methodname>Rectangle(int width, int + height)</methodname> with parameters <code language="java">width = + height = 1</code>.</para> + </callout> + + <callout arearefs="sd1_fig_rectangle_constructorCallsConstructor-2-co" + xml:id="sd1_fig_rectangle_constructorCallsConstructor-2"> + <para>Reusing constructor <methodname>Rectangle(int width, int + height)</methodname> with parameters <code language="java">width = + height = widthAndHeight</code>.</para> + </callout> + </calloutlist> + <figure xml:id="sd1_fig_rectangleThreeConstructorsInstances"> <title>Instances by overloaded constructors</title>