Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Require a class definition as defined below: Require a class definition for the Circle class. The class has two instance variables, center and radius.

1. Require a class definition as defined below: Require a class definition for the Circle class. The class has two instance variables, center and radius. Note that the center is a tuple and contains two values - the x and y values. Use data mangling for naming your instance variables. When the object is created, your code should check to make sure that the radius is strictly positive. If not, print an appropriate message. In addition to the constructor, your class definition should also have the following methods:

1. A constructor to initialize all instance variables.

2. Accessor methods for all instance variables

3. Mutator methods for all instance variables

4. A __str__() method to print the center and radius of each circle object.

5. The definition should also have the following methods

a. get_area(): This should compute and return the area of the circle

b. get_circumference(): This should compute and return the circumference of the circle

c. grow(): Each time this method is called, the radius of the circle object will increase by 1

d. shrink(): Each time this method is called, the radius of the circle object will decrease by 1

2. Require a driver class to test the Circle class definition.

Step 1: Create four Circle objects choosing appropriate values for the attributes and print out the four circle objects.

Step 2: For each Circle object, randomly peak either grow() or shrink() to run once. Then print out the new four circle objects.

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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Describe the different stages in KAM.

Answered: 1 week ago

Question

Show the properties and structure of allotropes of carbon.

Answered: 1 week ago