Answered step by step
Verified Expert Solution
Link Copied!

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:

  1. A parent/base class called shape with the following:
    1. Attributes - name : string
    2. Methods Constructor, getName(), toString()
  2. Derived class called circle inherits from shape, with the following:
    1. Attributes radius : double
    2. Methods
      1. Constructor
      2. toString
      3. getArea()
  3. Derived class called square inherits from shape, with the following:
    1. Attributes side : double
    2. Methods
      1. Constructor
      2. getArea()
      3. toString
  4. Derived class called sphere inherits from circle, with the following:
    1. Attributes
    2. Methods
      1. Constructor
      2. toString
      3. getVolume()
  5. Derived class called cylinder inherits from circle, with the following:
    1. Attributes height : double
    2. Methods
      1. Constructor
      2. getVolume
      3. toString
  6. Derived class called cube inherits from square, with the following:
    1. Attributes
    2. Methods
      1. Constructor
      2. getVolume
      3. toString

There are two interfaces you need to use. Take the decision to implement them whenever required

  1. Interface Volume
    1. Method - getVolume
  2. Interface Area
    1. Method - getArea
  3. A driver file

To do in driver class:

  1. Create 6 objects of Shape class as an array.
  2. Create objects of every class
  3. Print all the objects
  4. Print the area and volume of different objects

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

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

Students also viewed these Databases questions

Question

where does most ow-pressure systems form at the surface

Answered: 1 week ago