Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rectangle {
- private double width;
- private double length;
- public Rectangle(double width, double length) {
- if(width<0) this.width=0;
- else this.width=width;
- if (length<0) this.length=0;
- else this.length=length;
- }
- public double getWidth() {
- return width;
- }public class Cuboid extends Rectangle {
- private double height;
- public Cuboid(double width, double length, double height) {
- super(width, length);
- this.height = height<0 ? 0 : height;
- }
- public double getHeight() {
- return height;
- }
- public double getVolume() {
- return getArea()*getHeight();
- }
- }
- public double getLength() {
- return length;
- }
- public double getArea(){
- return getLength()*getWidth();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement