Question: Create a Java class hierarchy to represent oil volumes in barrels, gallons and pints using the UML diagrams below. Create abstract class Volume and classes
Create a Java class hierarchy to represent oil volumes in barrels, gallons and pints using the UML diagrams below. Create abstract class Volume and classes Volume1, Volume2.

- add and subtract() are invoked as a.add(b) and a.subtract(b). Both add() and subtract() must return Volume1s or Volume2s that have been converted
- toPints() returns the this object as a measurement in pints
- convert() converts this into a form where the number of gallons is greater than or equal to 0 and less than 42, number of pints is greater than or equal to 0 and less than 8
- You can add extra methods if needed or exclude an inherited method that is not overridden.
Volume > Comparable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
