Create the two classes described by the following UML. For simplicity, both classes should be in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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.\n", tank. getAquariumCapacity()); System.out.printf("The maximum number of fishes (2.5\") is %d.\n", 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]] 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.\n", tank. getAquariumCapacity()); System.out.printf("The maximum number of fishes (2.5\") is %d.\n", 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]]
Expert Answer:
Answer rating: 100% (QA)
Here is the implementation of the two classes Aquarium and RectangularAquarium along with the AquariumUsage class containing the main method java clas... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Data set Theory Assume an informational record with one association parent including matches (a, b) where a can't try not to be a parent of b. (a) Write a Datalog demand which gives the graph of...
-
(a) Explain how a limit worth may be tended to at run-time, both in a syntaxtree middle person and in collected code. What is the importance word "settled" already? [3 marks] (b) Give a model program...
-
Write a SET client SpellChecker that takes as a commandline argument the name of a file containing a dictionary of words, and then reads strings from standard input and prints any string that is not...
-
A machine that cost $9,050 with $3,940 of accumulated depreciation was traded in for a similar machine having a $5,870 cash price. An $820 tradein was offered by the seller. a. Calculate the book...
-
Define an annuity, explain the role it might play in an investment portfolio, and differentiate between a. single-premium and installment annuities. b. immediate and deferred annuities. c. fixed and...
-
Power required to drive a centrifugal pump is proportional to: (a) Speed (N) (b) \(\mathrm{N}^{2}\) (c) \(\mathrm{N}^{3}\) (d) \(\mathrm{N}^{4}\)
-
At December 31, 2011, Ashley Co. has outstanding purchase commitments for purchase of 150,000 gallons, at $6.20 per gallon, of a raw material to be used in its manufacturing process. The company...
-
What is MATLAB? Pros and cons.
-
Balance sheets for P Company and S Company on August 1, 2019, are as follows: Required: Prepare a workpaper for a consolidated balance sheet for P Company and its subsidiary on August 1, 2019, taking...
-
Consider a bicrystalline alloy undergoing solidification in a controlled envi- ronment. The alloy consists of two distinct crystal phases, each with unique solidification properties. The...
-
Briefly describe the links between the Facility manager, Director of patient care, compliance officer, risk management, hospital staff, patients, the community, the CMS, and the joint commission in...
-
You are required to update the cashbook with the below information relating to 2/10/x9 Cashbook balance as at 1/10/x9 300 (Debit) Cash sales 200 Phone bill 30 Drawings 50 What is the closing cashbook...
-
SummerCo provides snow removal service to various clients throughout the winter. It has purchased a snow removal blade for $65,000 that it will depreciate using declining balance depreciation at 25%....
-
Business Networking solution using Windows Server 2019 /2022 with 100 to 200 employees with at least 7 departments, with security groups. Including all the servers inside Windows 2019. Setup hardware...
-
Tricare program that is a Medicare-wraparound coverage for Tricare eligible beneficiaries who have Medicare Part A and B.MIPS is the Merit-based Incentive Payment Systems that most providers will...
-
Each group will think of a proposed business (see below) and develop some initial ideas about what considerations need to be taken into account for the company to reach profitability. Answer the...
-
ABC company leased new advanced computer equipment to STU Ltd on 1 January 2019.STULtd has to pay annual rental of $290,000 starting at 1 January 2019. It is a four years lease with ultimate rental...
-
Janie graduates from high school in 2012 and enrolls in college in the fall. Her parents pay $4,000 for her tuition and fees. a. Assuming Janie's parents have AGI of $170,000, what is the American...
-
Marty is a sales consultant. Marty incurs the following expenses related to entertainment of his clients in 2012: Dues to a country club......................................................$4,500...
-
Carl and Jenny adopt a Russian orphan. The adoption takes 2 years and two trips to Russia and is final in 2012. They pay $6,000 in 2011 and $7,500 in 2012 of qualified adoption expenses, and have AGI...
-
Which of the characteristics put forth by Chaterji to describe the factor-based approach is/are correct? A. Only Characteristic 1 B. Only Characteristic 2 C. Both Characteristic 1 and Characteristic...
-
The change in the annual spending rate, in conjunction with the boards expectations regarding future enrollment and the need for endowment support, could justify that KUEs target weight for: A....
-
Based on Exhibits 1 and 2, to attempt to profit from the short-term excess return forecast, Capara should increase KUEs portfolio allocation to: A. developed markets equity and decrease its...
Study smarter with the SolutionInn App