Question: Java Programming 5 th edition Chapter 10 Inheritance Programs Part 1 Number 3 on page 719 which creates a Point class with 2 instance variables;

Java Programming 5th edition Chapter 10 Inheritance Programs

Part 1

Number 3 on page 719 which creates a Point class with 2 instance variables; the xCoordinate and yCoordinate. It should have a default constructor and a values constructor. Also include a set method that sets both attributes, a get method for each attribute, and a method that redefines toString() to print the attributes as follows.

point: (x, y)

Part 2

Do number 4 on page 719 which creates a Circle class that extends the Point class above. It adds the radius, circumference, and area instance variables. It should have a default constructor and a values constructor (circumference and area will be 0.0). Include a set method that sets the coordinates and radius attributes, get methods that get each of the 3 new attributes, and a method that redefines toString() to print all attributes. Also, include methods to calculate the circumference and area of the circle. Use pie = 3.141593. Make sure your methods dont repeat the code already written in the Point class.

Circumference = 2pier

Area = pier2

Part 3

Do number 5 on page 719 which creates a Cylinder class that extends the Circle class above. It adds the height, surfaceArea, and volume instance variables. It should have a default constructor and a values constructor (circumference and circleArea will be calculated from the Circle class, surfaceArea and volume will be 0.0). Include a set method for the center point coordinates, radius, height, circumference, and circleArea attributes (circumference and circleArea will be calculated from the Circle class), get methods that get each of the 3 new attributes, and a method that redefines toString() to print all attributes. Also, include methods to calculate the surfaceArea and volume of the cylinder. Make sure your methods dont repeat the code already written in the Circle class.

surfaceArea = 2 * circleArea + circleCircumference * cylinderHeight

volume = circleArea * cylinderHeight

Hints:

1.In the values constructor and the set method youll need to call the methods to calculate circumference and area so that they have values to use in calculating the surface area and volume.

2.The methods in the Circle class to calculate circumference and area will need to return those values for use in the Cylinder class.

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 Databases Questions!