Question: Complete the code for Rectangle.java and Block.java. DO NOT CHANGE ANY METHOD HEADERS. When doing Block.java you should use calls to superclass methods wherever possible.

Complete the code for Rectangle.java and Block.java. DO NOT CHANGE ANY METHOD HEADERS. When doing Block.java you should use calls to superclass methods wherever possible. Look over the Shape hierarchy example for help. Note: You will only need to compare two Rectangles or compare two Blocks., It does not make sense to compare a Rectangle and a Block

public class Rectangle implements Comparable { private double length; private double width;

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() {

} }

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!