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)
Heres the implementation of the two classes Aquarium and RectangularAquarium in the AquariumUsagejav... 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
-
List as many thick or thin film application as you can from familiar industrial or consumer products. For each, list the properties required for the film to function effectively?
-
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...
-
The infrared absorption spectrum of 1H35Cl has its strongest band at 8.65 x 1013Hz. For this molecule, D0 = 4.43 eV. (a) Find De for 1H35Cl. (b) Find D0 for 2H35Cl
-
In 2023, Jasmine and Thomas, a married couple, have taxable income of $150,000. If they were to file separate tax returns, Jasmine would have reported taxable income of $140,000 and Thomas would have...
-
Accumulated other comprehensive income (AOCI) appears as a subsection of shareholders equity on the balance sheet. Discuss the components of AOCI. What information does the AOCI convey to financial...
-
In 2015, a city opens a municipal landll, which it will account for in an enterprise fund. It estimates capacity to be 6 million cubic feet and usable life to be 20 years. To close the landll, the...
-
The following information is available for the Duncan Co., which produces two types of high-end coffee makers. Type 1 Type 2 Total Sales volume (units) 300 400 700 Revenue $70,000 $78,000 $148,000...
-
Here are my code. And the documentation for reference class DeliveryPlanner_PartA: """ Required methods in this class are: plan_delivery(self, debug = False) which is stubbed out below. You may not...
-
What is India's dominant culture?
-
How does an auditor using an ITF keep from contaminating client files with data designed to test the clients processing? Describe the two approaches most often used.
-
What are the types of test plans?
-
Identify five ways in which an auditor might utilize spreadsheet software in conducting an audit.
-
When is a DR prepared?
-
How do you prepare TRs?
-
Which financial statement reflects a company's financial position at a specific point in time?
-
How do the principles of (a) Physical controls and (b) Documentation controls apply to cash disbursements?
-
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...
-
A variation on the critical path problem is the task scheduling problem. In this problem, unlike the critical path problem, explicit attention is paid to how many workers are available to do tasks,...
-
Cables are to connect several components of a sound system. The vertices in the graph below represent the components, and the edges are possible connections. The matrix above gives the lengths of...
-
Prove or disprove. Let \(T\) be a minimal spanning tree of an undirected graph \(G\) and fix a vertex \(v_{0}\). Then for each vertex \(u eq v_{0}\), the cost of the path in \(T\) from \(v_{0}\) to...
Study smarter with the SolutionInn App