Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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:

image text in transcribed

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(): String

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions