Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

} }

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago