Question: Create the two classes described by the following UML. For simplicity, both classes should be in the same file called AquariumUsage.java. (Neither of these

Create the two classes described by the following UML. For simplicity, bothclasses should be in the same file called AquariumUsage.java. (Neither of these

Create the two classes described by the following UML. For simplicity, both classes should be in the same file called AquariumUsage.java. (Neither of these two classes below should be declared public.) -type: String - numberFishes : int + Aquarium (type : String, numberFishes : int) + Aquarium (type : String) + getType (): String + getNumberFishes (): int + setType (type: String): void + setNumberFishes (numberFishes : int) : void + toString(): String - length: double - width: double - height: double Aquarium RectangularAquarium + RectangularAquarium (type: String, numberFishes : int, length: double, width: double, height : double) + RectangularAquarium (type: String, length: double, width: double, height : double) + getLength (): double + getWidth (): double + getHeight (): double + getAquarium Capacity (): double + getMaxFishNumber (fishSize : double): int + toString () : String Additional information: 1. You are required to use constructor chaining for the two Aquarium constructors. When unspecified or negative, the number of fishes should be set to zero. 2. The RectangularAquarium constructors should also make use of constructor chaining. 3. The aquarium dimensions are in feet. You can assume they are larger than 0 (no need for validation code). 4. The aquarium capacity should be expressed in gallons (1 cubic foot = 7.48052 gallons). 5. A rule of thumb for the maximum of fishes a tank should contain is "1 inch of fish per gallon". The average fish size is passed to the method and the tank capacity in gallons is available... Add 10% to the result and round to the nearest integer. 6. The toString() method for the RectangularAquarium class must both override and make use or the toString() method for the Aquarium class. When done, add a third class to your AquariumUsage file. Use the code provided below for that third class (Note this class is public AND contain main()): public class AquariumUsage { } public static void main(String[] args) { RectangularAquarium tank; tank = new RectangularAquarium ("soft water", 5, 2, 2.5); tank= new RectangularAquarium ("marine", -2, 3.0, 2.0, 2.5); System.out.println(tank); System.out.println (tank); System.out.printf("The capacity of my tank is %.1f gallons. ", tank. getAquariumCapacity()); System.out.printf("The maximum number of fishes (2.5\") is %d. ", tank.getMaxFishNumber (2.5)); tank.setNumber Fishes (36); System.out.println(tank); Sample Output: RectangularAquarium [length=3.0, width=2.0, height=2.5, Aquarium [type=marine, number Fishes=0]] RectangularAquarium [length=5.0, width=2.0, height=2.5, Aquarium [type=soft water, number Fishes=0]] The capacity of my tank is 187.0 gallons. The maximum number of fishes (2.5") is 82. RectangularAquarium [length=5.0, width=2.0, height=2.5, Aquarium [type=soft water, number Fishes=36]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the implementation of the two classes Aquarium and RectangularAquarium in the AquariumUsagejav... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!