Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Design a class named RegularPolygon containing the following: 1 . An int data field named n defines the number of sides in the polygon.

Python
Design a class named RegularPolygon containing the following:
1. An int data field named n defines the number of sides in the polygon.
2. A float data field named side stores the length of the side.
3. A float data field named x defines the x-coordinate of the center of the polygon with a default value of 0.
4. A float data field named y defines the y-coordinate of the center of the polygon with a default value of 0.
5. A constructor that creates a regular polygon with the specified n (default 3), side (default 1), x (default 0), and y (default 0).
6. The accessor and mutator methods for all data fields.
7. The method getPerimeter() returns the perimeter of the polygon.
8. The method getArea() returns the area of the polygon.
Create three RegularPolygon objects
A. using RegularPolygon()
B. using RegularPolygon(6,4)
C. using RegularPolygon(10,4,5.6,7.8)

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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions