Nice TWiki > Doc > ShapesBeginnerExample (r1.1 vs. r1.4) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Doc . { Changes | Index | Search | Go }
 <<O>>  Difference Topic ShapesBeginnerExample (r1.4 - 10 Jan 2004 - IsaacGouy)

 <<O>>  Difference Topic ShapesBeginnerExample (r1.3 - 24 Dec 2003 - IsaacGouy)
Changed:
<
<

moveBy(this@Shape, dx, dy){

>
>

moveBy(Shape this, dx, dy){

Changed:
<
<

setHeight(this@Rectangle, height){

>
>

setHeight(Rectangle this, height){

Changed:
<
<

setRadius(this@Circle, radius){

>
>

setRadius(Circle this, radius){

Changed:
<
<

moveBy(this@Shape, dx, dy){

>
>

moveBy(Shape this, dx, dy){

Changed:
<
<

-- IsaacGouy - 29 Aug 2003

>
>

-- IsaacGouy - 24 Dec 2003


 <<O>>  Difference Topic ShapesBeginnerExample (r1.2 - 17 Sep 2003 - IsaacGouy)
Changed:
<
<

void moveTo(int newx, int newy){

>
>

void moveTo(int newx, int newy); moveTo(newx, newy) {

Changed:
<
<

void setWidth(int width){

>
>

void setWidth(int width); setWidth(int width){

Changed:
<
<

void moveTo(int newx, int newy){

>
>

void moveTo(int newx, int newy);

Changed:
<
<

method implementation - for parameters matching Shape (and subclasses), int and int.

>
>

method definition and implementation - for parameters matching Shape (and subclasses), int and int.


 <<O>>  Difference Topic ShapesBeginnerExample (r1.1 - 29 Aug 2003 - IsaacGouy)
Added:
>
>

%META:TOPICINFO{author="IsaacGouy" date="1062200039" format="1.0" version="1.1"}% %META:TOPICPARENT{name="CodeExamples"}%

/* Please try the NoviceExamples before the BeginnerExamples
To compile:
   nicec --sourcepath=.. -a shapes.jar shapes
*/



abstract class Shape {                  
   int x;
   int y;               
   
   void moveTo(int newx, int newy){
      x = newx; 
      y = newy;
   }
         
   void moveBy(int dx, int dy);   
}

moveBy(this@Shape, dx, dy){
   x += dx; 
   y += dy;
}



class Rectangle extends Shape {   
   private int width;
   private int height;            
   
   void setHeight(int height);

   void setWidth(int width){
      this.width = width;
   }   
}
   
setHeight(this@Rectangle, height){
   this.height = height;
}



class Circle extends Shape {            
   private int radius;
      
   void setRadius(int radius);   
}

setRadius(this@Circle, radius){
   this.radius = radius;
}



/* Notes - language
   Compare with other OO languages
http://onestepback.org/articles/poly/
http://www.angelfire.com/tx4/cus/shapes/

   void moveTo(int newx, int newy){
Within a class definition, declare a method  
with a method implementation for the class.

   void moveBy(int dx, int dy);   
Within a class definition, declare a method.  

   moveBy(this@Shape, dx, dy){
Outside of the class definition, provide a
method implementation - for parameters matching 
Shape (and subclasses), int and int.
*/
-- IsaacGouy - 29 Aug 2003

Topic ShapesBeginnerExample . { View | Diffs | r1.4 | > | r1.3 | > | r1.2 | More }
Revision r1.1 - 29 Aug 2003 - 23:33 GMT - IsaacGouy
Revision r1.4 - 10 Jan 2004 - 15:43 GMT - IsaacGouy
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.