Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

Discuss all branches of science

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago