Question
In Euclidean geometry, a rhombus is a simple quadrilateral whose four sides all have the same length. If lengths of each of the sides are
In Euclidean geometry, a rhombus is a simple quadrilateral whose four sides all have the same length. If lengths of each of the sides are a and the distance between the parallel sides (known as height) is h, then the area of the rhombus is defined as a h. Suppose that you already have a class named Rhombus that can hold a and h. The class has a method to compute the area as well. The class is as follows.
public class Rhombus {
private double a, h;
Rhombus nextRhombus;
Rhombus(){
h=1; a=h;
}
Rhombus(double aa, double hh){
a=aa; h=hh;
}
public double geta(){
return a;
}
public double geth(){
return h;
}
public double getArea(){
return a*h;
}
public boolean isSquare(){
return a==h;
}
}
Notice that Rhombus nextRhombus; in the Rhombus class can be used to construct a linked list.
(15 points) Now, you have another class named RhombusProcessor that has Rhombus objects in an array in the main method. Write a method named getSquares in the RhombusProcessor class to copy only the Rhombus objects that represent squares. The getSquares method must return these square shaped Rhombus objects using a linked list in the same oder they appear in the original list. Notice that you will only return the head of the linked list. The program is partially written; you just need to write the getSquares method in the space provided within the RhombusProcessor class. The expected header is public static Rhombus getSquares(Rhombus[] r).
public class RhombusProcessor {
public static Rhombus getSquares(Rhombus[] r){
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