Abstract type: Difference between revisions
Content added Content deleted
Line 1,425: | Line 1,425: | ||
To be of a particular property, a list of methods can tagged as required. For instance, in order to be Comparable, a class should implement <= |
To be of a particular property, a list of methods can tagged as required. For instance, in order to be Comparable, a class should implement <= |
||
<lang Oforth>Property new: |
<lang Oforth>Property new: Spherical(r) |
||
Spherical method: radius { @r } |
|||
Spherical method: setRadius(r) { r := r } |
|||
Spherical method: perimeter { @r 2 * Pi * } |
|||
Spherical method: surface { @r sq Pi * 4 * } |
|||
Object Class new: Ballon(color) |
Object Class new: Ballon(color) |
||
Ballon is: |
Ballon is: Spherical |
||
Ballon method: initialize(color, r) { color := color self setRadius(r) } |
Ballon method: initialize(color, r) { color := color self setRadius(r) } |
||
Object Class new: Planete(name) |
Object Class new: Planete(name) |
||
Planete is: |
Planete is: Spherical |
||
Planete method: initialize(n, r) { n := name self setRadius(r) }</lang> |
Planete method: initialize(n, r) { n := name self setRadius(r) }</lang> |
||