Index: doc/example-scripts/rosetta-polymorphism.html =================================================================== diff -u -N -r24cb8f4bffd49c9375c1c64aa0610933b62511bb -rc4f449cb353be812ba6502ef8e9587e87881f59b --- doc/example-scripts/rosetta-polymorphism.html (.../rosetta-polymorphism.html) (revision 24cb8f4bffd49c9375c1c64aa0610933b62511bb) +++ doc/example-scripts/rosetta-polymorphism.html (.../rosetta-polymorphism.html) (revision c4f449cb353be812ba6502ef8e9587e87881f59b) @@ -1,872 +1,872 @@ - - - - - -Listing of doc/example-scripts/rosetta-polymorphism.tcl - - - - - -
-
-

Rosetta Example: Polymorphism

-
- -
-
-
package req nx
-
-nx::Class create Point {
-
-  :property x:double
-  :property y:double
-
-  :public method print {} {
-    return "Point(${:x},${:y})"
-  }
-}
-
-nx::Class create Circle -superclass Point {
-
-  :property radius:double
-
-  :public method print {} {
-    return "Circle(${:x},${:y},${:radius})"
-  }
-}
-
-

Demonstrating the behavior in a shell:

-

Create a point and get the print string:

-
-
-
% set p [Point new -x 1.0 -y 2.0]
-% $p print
-Point(1.0,2.0)
-

Get the x coordinate of this point:

-
-
-
% $p cget -x
-1.0
-

Create a circle:

-
-
-
% set c [Circle new -x 3.0 -y 4.0 -radius 5.0]
-

Copy the circle

-
-
-
% set d [$c copy]
-

Change the radius of the copied circle:

-
-
-
% $d configure -radius 1.5
-

Print the two circles:

-
-
-
% $c print
-Circle(3.0,4.0,5.0)
-
-% $d print
-Circle(3.0,4.0,1.5)
-
-
-
-
-

- - - + + + + + +Listing of doc/example-scripts/rosetta-polymorphism.tcl + + + + + +
+
+

Rosetta Example: Polymorphism

+
+ +
+
+
package req nx
+
+nx::Class create Point {
+
+  :property x:double
+  :property y:double
+
+  :public method print {} {
+    return "Point(${:x},${:y})"
+  }
+}
+
+nx::Class create Circle -superclass Point {
+
+  :property radius:double
+
+  :public method print {} {
+    return "Circle(${:x},${:y},${:radius})"
+  }
+}
+
+

Demonstrating the behavior in a shell:

+

Create a point and get the print string:

+
+
+
% set p [Point new -x 1.0 -y 2.0]
+% $p print
+Point(1.0,2.0)
+

Get the x coordinate of this point:

+
+
+
% $p cget -x
+1.0
+

Create a circle:

+
+
+
% set c [Circle new -x 3.0 -y 4.0 -radius 5.0]
+

Copy the circle

+
+
+
% set d [$c copy]
+

Change the radius of the copied circle:

+
+
+
% $d configure -radius 1.5
+

Print the two circles:

+
+
+
% $c print
+Circle(3.0,4.0,5.0)
+
+% $d print
+Circle(3.0,4.0,1.5)
+
+
+
+
+

+ + +