In this exercise, you are going to complete the Rectangle class. You need to complete the class so that you can print and compare two rectangles. Once complete, use the RectangleTester to test the results. In the tester class, you are given 3 rectangles that you should print and compare. Sample results are provided below. Sample output A rectangle with a width of 5 and a height of 4 A rectangle with a width of 5 and a height of 4 A rectangle with a width of 10 and a height of 4 true false
In this exercise, you are going to complete the Rectangle class. You need to complete the class so that you can print and compare two rectangles.
Once complete, use the RectangleTester to test the results. In the tester class, you are given 3 rectangles that you should print and compare. Sample results are provided below.
Sample output
A rectangle with a width of 5 and a height of 4 A rectangle with a width of 5 and a height of 4 A rectangle with a width of 10 and a height of 4 true false
===========================================
public class RectangleTester
{
public static void main(String[] args)
{
Rectangle rect1 = new Rectangle(5, 4);
Rectangle rect2 = new Rectangle(5, 4);
Rectangle rect3 = new Rectangle(10, 4);
// Print all three rectangles
// Print one true statement comparing rectangles
// Print one false statment comparing rectangles
}
}
===========================================
public class Rectangle{
private int width;
private int height;
public Rectangle(int width, int height) {
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images