Question
A square is an equilateral and equiangular polygon by default. Implement these properties of a square to design a class named Square. The class contains
A square is an equilateral and equiangular polygon by default. Implement these properties of a square to design a class named Square. The class contains a private data field named x and y that store the respective coordinates of the square. All data fields inside the class are private, therefore the class must contain accessor and mutator methods. Calculate the area and perimeter of the square using two different methods. Write a test program to create two squares with the value
- (4,5) where 10 refers to the number of sides and 5 refers to the length of each side
- (4, 2, 8, 2.8) where 4 is the number of sides, 2 is the length of each side, 8 & 2.8 are (x,y) coordinates of the square on a plane.
Display the area and perimeter of each square.
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