Create a class Rectangle with parameters length, breadth, and color. Use appropriate data types and access specifiers. Write overloaded constructors to create objects of rectangle. First constructor takes all the three parameters. Second constructer takes two parameters length and breadth. If only one parameter is given then user creates square of red color. Write methods to set and get the values of length, breadth and color. Write methods to find length of the diagonal of rectangle and to display the complete details of rectangle with area. Create another class TestRectangle which uses all constructors to create the different objects, uses appropriate set and get methods wherever required. Display the details of every rectangle.
Create a class Rectangle with parameters length, breadth, and color. Use appropriate data types and
access specifiers. Write overloaded constructors to create objects of rectangle. First constructor takes
all the three parameters. Second constructer takes two parameters length and breadth. If only one
parameter is given then user creates square of red color. Write methods to set and get the values of
length, breadth and color. Write methods to find length of the diagonal of rectangle and to display the
complete details of rectangle with area. Create another class TestRectangle which uses all
constructors to create the different objects, uses appropriate set and get methods wherever required.
Display the details of every rectangle.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps