rev 502 - in trunk: docs/tutorial pr/tutorial
SVN User <[email protected]> Tue, 18 May 2004 16:04:11 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-05-18 16:04:07 -0400 (Tue, 18 May 2004)
New Revision: 502
Modified:
trunk/docs/tutorial/index2.htm
trunk/docs/tutorial/tutorial9.htm
trunk/pr/tutorial/tut12.pr
Log:
changed tut12 Solid example to use init_
Modified: trunk/docs/tutorial/index2.htm
===================================================================
--- trunk/docs/tutorial/index2.htm 2004-05-18 19:06:22 UTC (rev 501)
+++ trunk/docs/tutorial/index2.htm 2004-05-18 20:04:07 UTC (rev 502)
@@ -88,8 +88,7 @@
<li><a href="tutorial9.htm#mulinh">6.7 Multiple Inheritance</a>
<ul>
<li><a href="tutorial9.htm#miwarn">Dangers of Multiple Inheritance</a>
- <li><a href="tutorial9.htm#miex">Example</a>
- <li><a href="tutorial9.htm#mixin">Mix-In</a>
+ <li><a href="tutorial9.htm#miex">Example</a>
</ul>
</ul>
</ul>
Modified: trunk/docs/tutorial/tutorial9.htm
===================================================================
--- trunk/docs/tutorial/tutorial9.htm 2004-05-18 19:06:22 UTC (rev 501)
+++ trunk/docs/tutorial/tutorial9.htm 2004-05-18 20:04:07 UTC (rev 502)
@@ -32,7 +32,7 @@
<br>
<table width="629" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffee" height="1707">
<tr>
- <td height="3212" valign="top">
+ <td height="3165" valign="top">
<p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="init"></a>6.4
Object Initialization</font></p>
<p>When you create a thousand rectangles, you don't want them to all have
@@ -176,18 +176,17 @@
has multiple links to start from. If different parents on different
paths have the same attribute you may not get the one you expect.</p>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="miex"></a></font>Let's
- add a new prototype to our Rectangle example called Solid. This will
- be a "mix-in" prototype that has a "depth" attribute
- that makes our rectangles into three dimensional objects when added
- to them. It will also add a "volume" method that calculates
- the volume of the solid. Our goal is to be able to just add the Solid
- prototype to any Rectangle or Rectangle sub-type to make a Solid object.</p>
+ add a new prototype to our Rectangle example called Solid. This prototype
+ has a "depth" attribute that makes our rectangles into three
+ dimensional objects when added to them. It will also add a "volume"
+ method that calculates the volume of the solid. Our goal is to be able
+ to just add the Solid prototype to any Rectangle or Rectangle sub-type
+ to make a solid object.</p>
<p>In this example we will add the Solid prototype to the Square we developed
before to turn the square into a cube. Our code for the Square and Rectangle
here is the same. We are just adding the Solid prototype and using it
to make the new prototype Cube.</p>
- <pre>
-# Prothon source file tut12.pr
+ <pre># Prothon source file tut12.pr
object Rectangle:
width = 0
@@ -207,7 +206,7 @@
object Solid:
depth = 0
- def initSolid(depth):
+ def init_(depth):
self.depth = depth
def volume():
@@ -216,22 +215,18 @@
object Cube(Square, Solid): # Cube has two prototypes
def init_(width):
Square.init_{self}(width)
- self.initSolid(width)
+ Solid.init_{self}(width)
def str_():
return '<cube:'+self.width+'>'
cube = Cube(3)
-print cube, cube.area(), cube.volume()</pre>
+print cube, cube.area(), cube.volume()
+</pre>
<p>Here is the output: </p>
<pre><cube:3> 9 27</pre>
- <font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="mixin"></a></font>Note
- that we used a different type of initialization for Solid. Solid was only
- designed to be a mix-in and to be used this way, so its initialization
- is a simple method. You can see that it and the init_ call above it both
- have to specify "self" as the target "self" of the
- calls. </td>
+ </td>
</tr>
</table>
<table width="630" border="0" cellpadding="0" cellspacing="0">
Modified: trunk/pr/tutorial/tut12.pr
===================================================================
--- trunk/pr/tutorial/tut12.pr 2004-05-18 19:06:22 UTC (rev 501)
+++ trunk/pr/tutorial/tut12.pr 2004-05-18 20:04:07 UTC (rev 502)
@@ -19,7 +19,7 @@
object Solid:
depth = 0
- def initSolid(depth):
+ def init_(depth):
self.depth = depth
def volume():
@@ -28,7 +28,7 @@
object Cube(Square, Solid): # Cube has two prototypes
def init_(width):
Square.init_{self}(width)
- self.initSolid(width)
+ Solid.init_{self}(width)
def str_():
return '<cube:'+self.width+'>'