Question
In this assignment you will practice using inheritance. It is slightly shorter than usual because Unit 5's programming homework is longer. Q1 : Design and
In this assignment you will practice using inheritance. It is slightly shorter than usual because Unit 5's programming homework is longer.
Q1: Design and then implement three different classes that work together to define shapes: RoundShape, Cylinder, and Cone. For each class, store fundamental data about its size and provide methods to access and modify this data. In addition, provide appropriate methods to compute the area, and volume, for Cylinder and Cone. In your design, consider how shapes are related and thus where inheritance can be implemented. Don't create duplicate instance variables. Use the UML diagram below as a guide:
Create a main method which instantiates 2 Cylinder objects (any parameters), 2 Cone objects (any parameters), display them with ToString(), change one parameter (your choice) in each, and display them again. Attached is a base file that will help you define the different classes in the same file. Although it is not best practice, for this assignment we ask that you combine your classes into a single file to keep your files together. Remember that you MUST rename the base file and class to contain your last name. [25 points]
Sample Output:
RoundShape height double radius double RoundShape(r double, h double) get Radius() double getHeight double 0 setHeight(h double) void set Radius(r: double) void getArea0 double get Volum 0 double Cylinder Cone RoundShape(r double, h double RoundShape(r double, h double getArea0 double getArea0 double getVolume() double getVolume() double toString(): String toString(): StringStep 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