java:class_constructors

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
java:class_constructors [2017/02/16 11:03]
gthanos
java:class_constructors [2017/03/01 15:33]
gthanos [Πολλαπλοί κατασκευαστές σε μία κλάση]
Line 31: Line 31:
  
 <code java> <code java>
-code java Rectangle.java>​ 
 public class Rectangle { public class Rectangle {
   int width;   int width;
Line 57: Line 56:
 public Rectangle(int initWidth, int initHeight, Point initOrigin);​ public Rectangle(int initWidth, int initHeight, Point initOrigin);​
 public Rectangle(int initWidth, int initHeight, int xPos, int yPos); public Rectangle(int initWidth, int initHeight, int xPos, int yPos);
 +public Rectangle(int initWidth, int initHeight);​
 </​code>​ </​code>​
  
Line 79: Line 79:
     height = initHeight;     height = initHeight;
     origin = new Point(xPos,​yPos);​     origin = new Point(xPos,​yPos);​
 +  }
 +  ​
 +  public Rectangle(int initWidth, int initHeight) {
 +    width = initWidth;
 +    height = initHeight;
 +    origin = null;
   }   }
     ​     ​
java/class_constructors.txt · Last modified: 2017/03/01 15:33 by gthanos