Cube - } public int compareTo(Object o) { if (o instanceof...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
class Cube extends Rectangle implements Comparable { private double height; public Cube(String color, double length, double width, double height) { super(color, length, width); this.height= height; } public double getHeight() { return height; } public void setHeight(double height) { this.height = height; } public double calculateArea() { return 2*(super.getLength()*super.getWidth()) +2*(super.getLength()*height)+2*(super.getWidthjav()*height); } public double calculatePerimeter() { return 4*(super.getLength()+super.getWidth()+height);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public int compareTo(Object o) { if (o instanceof Cube) { Cube rect = (Cube)o; if (calculateArea() >rect.calculateArea()) { return -1; } if (calculateArea() ==rect.calculateArea()) { return 0; } if (calculateArea() <rect.calculateArea()) { return 1; } } return 100; } public boolean equals(Object o) { if (o instanceof Cube) { Cube cube = (Cube)o; if (height==(cube.height)) { return true; } else return false; } else return false; } }...
View Full Document

This note was uploaded on 03/25/2010 for the course CIS CIS3023 taught by Professor Seema during the Spring '10 term at Florida College.

Page1 / 2

Cube - } public int compareTo(Object o) { if (o instanceof...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online