diff --git a/lab-01/src/Circle.java b/lab-01/src/Circle.java index ba7354f..06c5bab 100644 --- a/lab-01/src/Circle.java +++ b/lab-01/src/Circle.java @@ -7,8 +7,7 @@ public class Circle extends _Point { * @param radius */ public Circle(double radius){ - super(); - setRadius(radius); + this(radius, 0, 0); } /** diff --git a/lab-01/src/Cylinder.java b/lab-01/src/Cylinder.java index 4720d26..79497c0 100644 --- a/lab-01/src/Cylinder.java +++ b/lab-01/src/Cylinder.java @@ -10,7 +10,7 @@ public class Cylinder extends Circle { public Cylinder(double r, double h){ super(r); // Circle with location 0, 0 and radius r. - this.height = h; + setHeight(h); //now a cylinder with radius r and height h at 0,0 } @@ -23,7 +23,7 @@ public class Cylinder extends Circle { */ public Cylinder(int x, int y,double r, double h){ super(r, x, y); //a circle with radius r at x,y - this.height = h; + setHeight(h); //cylinder with radius r and height h at x,y } diff --git a/lab-01/src/_Rectangle.java b/lab-01/src/_Rectangle.java index 91db46f..f980d00 100644 --- a/lab-01/src/_Rectangle.java +++ b/lab-01/src/_Rectangle.java @@ -9,9 +9,7 @@ public class _Rectangle extends _Point { * @param height height of rectangle */ public _Rectangle(double width, double height){ - super();// This might be useless. - this.height = height; - this.width = width; + this(0,0, width, height); } /** @@ -23,21 +21,21 @@ public class _Rectangle extends _Point { */ public _Rectangle(int x, int y, double w, double h){ super(x, y); - this.width = w; - this.height = h; + setHeight(h); + setWidth(w); } /** * set height of rectangle * @param h height */ - public void setHeight(double h){ this.height = h; } + public void setHeight(double h){ if (h >= 0) this.height = h; else this.height = 0;} /** * set width of rectangle * @param w width */ - public void setWidth(double w){ this.width = w; } + public void setWidth(double w){ if (w >= 0) this.width = w; else this.width = 0; } /** * returns height