Question: 1 . Create the class diagram for a class named Circle with fields named radius, area, and diameter. Include get methods for each field, but

1. Create the class diagram for a class named Circle with fields named radius, area, and diameter. Include get methods for each field, but include a set method only for the radius.
Also write the pseudocode for the class and include a constructor that sets the radius to 1.
When the radius is set, do not allow it to be zero or a negative number. When the radius is set, calculate the diameter (twice the radius) and the area (the radius squared times pi, which is approximately 3.14).
Code to go into the setRadius() method:
if rad <=0 then
radius =1
else
radius = rad
endif
diameter =2* radius
area =(radius * radius)*3.14

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!