Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem: Write a class named Rectangle to represent rectangles. The data fields are width, height, and color. Use double for width and height, and string
Problem: Write a class named Rectangle to represent rectangles. The data fields are width, height, and color. Use double for width and height, and string for color. Suppose that all the rectangles are the same color. You need to provide the accessor methods for the properties and a findArea method for computing the area of the rectangle The outline of the class is given as follows: public class Rectangle private double width = 1; private double height 1; private string color- ,white,, ; public Rectangle public Rectangle double width, double height, String color public double getWidth public void setWidth double width public double getHeight ) public void setHeight double height) ) public string getColor () ) public void setColor ( string color) () public double findArea public string toString public boolean equals Object obj) ) ALL METHODS MUST BE IMPLEMENTED!!! Write a client program(test class) to THOROUGHLY test the class Rectangle. In the client program, create two Rectangle objects. Assign any width and height to the two objects. Assign the first object the color red, and the second, yellow. Display the properties of both objects and find their areas
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