[POO] Shapes.java asserts
This commit is contained in:
parent
1c74cbb006
commit
2f8ec9d8b1
|
@ -4,8 +4,7 @@ class Circle {
|
||||||
public double radius;
|
public double radius;
|
||||||
|
|
||||||
public Circle(double radius) {
|
public Circle(double radius) {
|
||||||
if (radius <= 0)
|
assert radius > 0;
|
||||||
return;
|
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +13,7 @@ class Circle {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRadius(double radius) {
|
public void setRadius(double radius) {
|
||||||
|
assert radius > 0;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,7 @@ class Triangle {
|
||||||
public double side3;
|
public double side3;
|
||||||
|
|
||||||
public Triangle(double side1, double side2, double side3) {
|
public Triangle(double side1, double side2, double side3) {
|
||||||
if (side1 <= 0 || side2 <= 0 || side3 <= 0)
|
assert side1 > 0 && side2 > 0 && side3 > 0;
|
||||||
return;
|
|
||||||
this.side1 = side1;
|
this.side1 = side1;
|
||||||
this.side2 = side2;
|
this.side2 = side2;
|
||||||
this.side3 = side3;
|
this.side3 = side3;
|
||||||
|
@ -52,6 +51,7 @@ class Triangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSides(double side1, double side2, double side3) {
|
public void setSides(double side1, double side2, double side3) {
|
||||||
|
assert side1 > 0 && side2 > 0 && side3 > 0;
|
||||||
this.side1 = side1;
|
this.side1 = side1;
|
||||||
this.side2 = side2;
|
this.side2 = side2;
|
||||||
this.side3 = side3;
|
this.side3 = side3;
|
||||||
|
@ -80,8 +80,7 @@ class Rectangle {
|
||||||
public double side2;
|
public double side2;
|
||||||
|
|
||||||
public Rectangle(double side1, double side2) {
|
public Rectangle(double side1, double side2) {
|
||||||
if (side1 <= 0 || side2 <= 0)
|
assert side1 > 0 && side2 > 0;
|
||||||
return;
|
|
||||||
this.side1 = side1;
|
this.side1 = side1;
|
||||||
this.side2 = side2;
|
this.side2 = side2;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +90,7 @@ class Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSides(double side1, double side2) {
|
public void setSides(double side1, double side2) {
|
||||||
|
assert side1 > 0 && side2 > 0;
|
||||||
this.side1 = side1;
|
this.side1 = side1;
|
||||||
this.side2 = side2;
|
this.side2 = side2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue