Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design and implement these files: A parent/base class called shape with the following: Attributes - name : string Methods Constructor, getName(), toString() Derived class called
Design and implement these files:
- A parent/base class called shape with the following:
- Attributes - name : string
- Methods Constructor, getName(), toString()
- Derived class called circle inherits from shape, with the following:
- Attributes radius : double
- Methods
- Constructor
- toString
- getArea()
- Derived class called square inherits from shape, with the following:
- Attributes side : double
- Methods
- Constructor
- getArea()
- toString
- Derived class called sphere inherits from circle, with the following:
- Attributes
- Methods
- Constructor
- toString
- getVolume()
- Derived class called cylinder inherits from circle, with the following:
- Attributes height : double
- Methods
- Constructor
- getVolume
- toString
- Derived class called cube inherits from square, with the following:
- Attributes
- Methods
- Constructor
- getVolume
- toString
There are two interfaces you need to use. Take the decision to implement them whenever required
- Interface Volume
- Method - getVolume
- Interface Area
- Method - getArea
- A driver file
To do in driver class:
- Create 6 objects of Shape class as an array.
- Create objects of every class
- Print all the objects
- Print the area and volume of different objects
Step 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