Question
**IN JAVA** Complete the code for Rectangle.java and Block.java either as documents or as two java files. When doing Block.java you should use calls to
**IN JAVA**
Complete the code for Rectangle.java and Block.java either as documents or as two java files. When doing Block.java you should use calls to superclass methods wherever possible.
Rectangle.java
public class Rectangle implements Comparable
public Rectangle() {
}
public Rectangle(double l, double w) {
} public Rectangle(Rectangle r) {
} public double getLength() {
}
public double getWidth() {
}
public void setLength(double l) {
}
public void setWidth(double w) {
}
public double calcArea() {
}
public boolean equals(Rectangle r) { // tests whether this and r have the same dimension
} public static boolean sameDimensions(Rectangle r1, Rectangle r2) { // tests whether r1 and r2 have the same dimensions
}
public int compareTo(Rectangle r) { // based on area of this and r Rectangles
}
public static Rectangle largerArea(Rectangle r1, Rectangle r2) { // returns larger in area of r1 and r2
}
public Rectangle equivalentSquare() { // returns Rectangle which is a square of the same area
} public String toString() {
} }
Block.java
public class Block extends Rectangle { private double height;
public Block() {
}
public Block(double l, double w, double h) {
}
public Block(Block b) {
}
public double getHeight() {
}
public void setHeight(int h) {
}
public double calcArea() { // return surface area of this
}
public static double calcArea(Block b) { // return surface area of b }
public double calcVolume() { }
public boolean equals(Block b) { // based on dimensions of this and b being the same }
public int compareTo(Rectangle r) { // compare this and r Blocks based on volume } public Block equivalentCube() { // returns cube with same volume as this block } public String toString() { } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started