Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a class Container that has: instance variables: double height: // the height of the liquid container in centimeters double filledHeight; // the level of
Write a class Container that has:
- instance variables:
double height: // the height of the liquid container in centimeters
double filledHeight; // the level of liquid in the container (if it equals height, container is full)
- The class should have a constructor.
- A method public void fill(double cm) that increases the filled height of a container by the given amount in centimeters. This method will throw OverFillException if we are overfilling the container.
- A method public abstract double getBaseArea() that should return the base area of a given container.
- A method public double getVolume() to get the volume of the container.
(Note: volume = height * baseArea)
- A method public double getFilledVolume() to get the volume of water that is filling the container.
(Note: filled volume = filledHeight * baseArea)
- An equals method that compares two Container objects based on their filledVolume.
Write two classes CubicContainer and Cylinder that are subclasses of Container.
The class CubicContainer has:
- Instance variables representing width and length of the base.
- Calculation of the base area (area = width * length)
- Appropriate constructor.
The class Cylinder has:
- An instance variable radius, representing radius of the base.
- Calculation of the base area (area = 3.14 * radius2)
Appropriate constructor
(java).
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