Your task is to design and implement a Rectangle class and write a program that tests the class. This challenge will focus on encapsulating object-oriented programming concepts such as constructors, methods, and fields.
Skills to Practice
Defining and implementing classes.
Creating constructors.
Defining and using methods.
Working with object-oriented design principles.
Challenge Tasks
Create a console project named Challenge 5-1.
Draw the Class Diagram:
Draw the class diagram for the Rectangle class, including fields, constructors, and methods.
Class Implementation:
Define a class named Rectangle with the following specifications:
Two double data fields named width and height.
A default, no-argument constructor that creates a rectangle with default values of 1.
A constructor that creates a rectangle with specified width and height parameters.
A method named GetArea()* that returns the area of the rectangle.
A method named GetPerimeter()* that returns the perimeter of the rectangle.
Test Program:
Write a test program that creates two Rectangle objects:
One with a width of 10 and height of 50.
Another with a width of 12.5 and height of 25.8.
Display the width, height, area, and perimeter of each rectangle in this order.
* Use the naming convention matches your programming language/preference.