Location Class This class encapsulates a point on a simulation map. You should adhere to the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Location Class This class encapsulates a point on a simulation map. You should adhere to the following specifications for this object: 1. *Coord and yCoord cannot be less than zero. Need to catch and handle an InvalidCoordinateException for this object. 2. The empty-argument constructor initializes xCoord and yCoord to zero. 3. The preferred constructor initializes xCoord and yCoord with the data passed into it. 4. The update() method accepts the x and y coordinates and updates xCoord and yCoord. 5. The getCoordinates() method returns an array that contains the xCoord and yCoord (in that order) Animal Class The Animal class encapsulates a generic animal that can be sub-classed by other classes. You should adhere to the following specification for this object: 1. simID should be an integer greater than zero. Need to catch and handle an InvalidSimIDException for this object. 2. location should be a Location object that encapsulates the animals x and y coordinates in the simulation world. 3. full is a boolean that indicates that an animal is full after it has eaten. 4. rested is a boolean that indicates that animal is rested after it sleeps. 5. The empty-argument constructor should set: 。 simID = 0 。 location [0,0] 。 full = false 。rested true 6. The preferred constructor should set: 。 simID = data passed into the constructor 。 location = location passed into the constructor 。 full = false • rested = true 7. The eat() method should generate a random number between 0 and 1. If the number is .5 or lower, set full = false; otherwise, set full to true. 8. The sleep() method should generated a random number between 0 and 1. If the number is .5 or lower, set rested = false; otherwise, set rested to true. 9. Should have getters/setters for all instance variables <<abstract>> Animal #simID: int #location: Location #full:boolean #rested:boolean +Animal() +Animal(int simID, Location I) +eat(): boolean +sleep(): boolean BrownBear Class BrownBear is a subclass of Animal. You should adhere to the following specification for this object: 1. subSpecies should be one of the following: 。 Alaskan ° Asiatic о European 。 Grizzly 。 Kodiak 。 Siberian 2. Need to catch and handle an InvalidSubspeciesException for this object. 3. The empty-argument constructor should set: 。 simID = 0 。 location = [0,0] 。 full = false 。rested true 。 subSpecies = Alaskan 4. The preferred constructor should set: 。 simID = data passed into the constructor 。 location = location passed into the constructor 。 subSpecies = data passed into the constructor o full = false 。 rested = true 5. Should have getters/setters for all instance variables. 6. Should have a toString() method that just returns information about the object. Brown Bear -subSpecies: String +BrownBear() +Brown Bear(int simID, Location I, String subspecies) The Interfaces You will implement three interfaces, Flyable, Walkable, and Swimmable. 1. The BrownBear should move 3 units in the direction specified when it implements the Walkable interface. It should also update the Brown Bear's location object. 2. The Goldfinch should move 1 unit when it implements the Walkable interface. It should also update the Goldfinch's location object. 3. The BrownBear should move 2 units in the direction specified when it implements the Swimmable interface. (Don't worry about ensuring they are in a body of water - we'll ignore that detail for now.) It should also update the BrownBear's location object. 4. The Goldfinch should move to the location indicated by the parameter for fly for the Flyable interface. It should also update the Goldfinch's location object. <<Interface>> Flyable +fly(Location I):void <<Interface>> <<Interface>> Walkable Swimmable +walk(int direction):void +swim(int direction):void ********************************************* BrownBear Tests ********************************************* ************ Goldfinch Tests ******** ********************************************* ********************************************* Animal Tests ********************************************* ************* Location Tests ********** ********************************************* Generics The Application Class As with your previous programming project, the Application class should test all of your objects. This includes: ■ All constructors ■ All getters/setters ■ All methods (including those implemented through interfaces) ■ All exceptions ■ Animal is abstract - so you'll need to show that you cannot create instantiate a copy of it in your Application class. To ensure I can tell that you tested each object use the following headers to divide your tests: Generics The Java language provides an ArrayList class that can hold any type of object. Using the ArrayList class In your Application class: 1. Instantiate an ArrayList object that can hold any type of Animal. 2. Fill the ArrayList object with at least two animals of each type in the hierarchy 3. Iterate through the ArrayList object and call the toString() method on each Animal in the list to print out its data. Separate the ArrayList code from your other testing code using the following header Below is the complete UML Diagram for this project: Location -xCoord: int -yCoord: int +Location() +Location(int x, int y) +update(int x, int y) +getCoordinates(): int[] <<abstract>> Animal #simID: int Goldfinch -wingSpan: double +Goldfinch() +Goldfinch (int simID, Location I, wingSpan ws) Application +main(String[] args): void #location: Location #full:boolean #rested:boolean +Animal() +Animal(int simID, Location I) BrownBear +eat(): boolean +sleep(): boolean -subSpecies: String ID | +Brown Bear() | +Brown Bear(int simID, Location I, String subspecies) <<Interface>> <<Interface>> <<Interface>> Flyable Walkable Swimmable +fly(Location I):void +walk(int direction):void +swim(int direction):void ************* Generics Tests ************** ********************************************* Goldfinch Class Goldfinch is a subclass of Animal. You should adhere to the following specification for this object: 1. wingSpan should be a floating point number between 5.0 and 11.0 (in cm).Need to catch and handle an InvalidWingspanException for this object. 2. The empty-argument constructor should set: 。 simID = 0 。 location = [0,0] 。 full = false • rested = true 。 wingSpan = 9.0 3. The preferred constructor should set: 。 simID = data passed into the constructor 。 location = location passed into the constructor 。 wingSpan = data passed into the constructor 。 full = false 。 rested = true 4. Should have getters/setters for all instance variables. 5. Should have a toString() method that just returns information about the object. Goldfinch -wingSpan: double +Goldfinch() +Goldfinch(int simID, Location I, wingSpan ws) Location Class This class encapsulates a point on a simulation map. You should adhere to the following specifications for this object: 1. *Coord and yCoord cannot be less than zero. Need to catch and handle an InvalidCoordinateException for this object. 2. The empty-argument constructor initializes xCoord and yCoord to zero. 3. The preferred constructor initializes xCoord and yCoord with the data passed into it. 4. The update() method accepts the x and y coordinates and updates xCoord and yCoord. 5. The getCoordinates() method returns an array that contains the xCoord and yCoord (in that order) Animal Class The Animal class encapsulates a generic animal that can be sub-classed by other classes. You should adhere to the following specification for this object: 1. simID should be an integer greater than zero. Need to catch and handle an InvalidSimIDException for this object. 2. location should be a Location object that encapsulates the animals x and y coordinates in the simulation world. 3. full is a boolean that indicates that an animal is full after it has eaten. 4. rested is a boolean that indicates that animal is rested after it sleeps. 5. The empty-argument constructor should set: 。 simID = 0 。 location [0,0] 。 full = false 。rested true 6. The preferred constructor should set: 。 simID = data passed into the constructor 。 location = location passed into the constructor 。 full = false • rested = true 7. The eat() method should generate a random number between 0 and 1. If the number is .5 or lower, set full = false; otherwise, set full to true. 8. The sleep() method should generated a random number between 0 and 1. If the number is .5 or lower, set rested = false; otherwise, set rested to true. 9. Should have getters/setters for all instance variables <<abstract>> Animal #simID: int #location: Location #full:boolean #rested:boolean +Animal() +Animal(int simID, Location I) +eat(): boolean +sleep(): boolean BrownBear Class BrownBear is a subclass of Animal. You should adhere to the following specification for this object: 1. subSpecies should be one of the following: 。 Alaskan ° Asiatic о European 。 Grizzly 。 Kodiak 。 Siberian 2. Need to catch and handle an InvalidSubspeciesException for this object. 3. The empty-argument constructor should set: 。 simID = 0 。 location = [0,0] 。 full = false 。rested true 。 subSpecies = Alaskan 4. The preferred constructor should set: 。 simID = data passed into the constructor 。 location = location passed into the constructor 。 subSpecies = data passed into the constructor o full = false 。 rested = true 5. Should have getters/setters for all instance variables. 6. Should have a toString() method that just returns information about the object. Brown Bear -subSpecies: String +BrownBear() +Brown Bear(int simID, Location I, String subspecies) The Interfaces You will implement three interfaces, Flyable, Walkable, and Swimmable. 1. The BrownBear should move 3 units in the direction specified when it implements the Walkable interface. It should also update the Brown Bear's location object. 2. The Goldfinch should move 1 unit when it implements the Walkable interface. It should also update the Goldfinch's location object. 3. The BrownBear should move 2 units in the direction specified when it implements the Swimmable interface. (Don't worry about ensuring they are in a body of water - we'll ignore that detail for now.) It should also update the BrownBear's location object. 4. The Goldfinch should move to the location indicated by the parameter for fly for the Flyable interface. It should also update the Goldfinch's location object. <<Interface>> Flyable +fly(Location I):void <<Interface>> <<Interface>> Walkable Swimmable +walk(int direction):void +swim(int direction):void ********************************************* BrownBear Tests ********************************************* ************ Goldfinch Tests ******** ********************************************* ********************************************* Animal Tests ********************************************* ************* Location Tests ********** ********************************************* Generics The Application Class As with your previous programming project, the Application class should test all of your objects. This includes: ■ All constructors ■ All getters/setters ■ All methods (including those implemented through interfaces) ■ All exceptions ■ Animal is abstract - so you'll need to show that you cannot create instantiate a copy of it in your Application class. To ensure I can tell that you tested each object use the following headers to divide your tests: Generics The Java language provides an ArrayList class that can hold any type of object. Using the ArrayList class In your Application class: 1. Instantiate an ArrayList object that can hold any type of Animal. 2. Fill the ArrayList object with at least two animals of each type in the hierarchy 3. Iterate through the ArrayList object and call the toString() method on each Animal in the list to print out its data. Separate the ArrayList code from your other testing code using the following header Below is the complete UML Diagram for this project: Location -xCoord: int -yCoord: int +Location() +Location(int x, int y) +update(int x, int y) +getCoordinates(): int[] <<abstract>> Animal #simID: int Goldfinch -wingSpan: double +Goldfinch() +Goldfinch (int simID, Location I, wingSpan ws) Application +main(String[] args): void #location: Location #full:boolean #rested:boolean +Animal() +Animal(int simID, Location I) BrownBear +eat(): boolean +sleep(): boolean -subSpecies: String ID | +Brown Bear() | +Brown Bear(int simID, Location I, String subspecies) <<Interface>> <<Interface>> <<Interface>> Flyable Walkable Swimmable +fly(Location I):void +walk(int direction):void +swim(int direction):void ************* Generics Tests ************** ********************************************* Goldfinch Class Goldfinch is a subclass of Animal. You should adhere to the following specification for this object: 1. wingSpan should be a floating point number between 5.0 and 11.0 (in cm).Need to catch and handle an InvalidWingspanException for this object. 2. The empty-argument constructor should set: 。 simID = 0 。 location = [0,0] 。 full = false • rested = true 。 wingSpan = 9.0 3. The preferred constructor should set: 。 simID = data passed into the constructor 。 location = location passed into the constructor 。 wingSpan = data passed into the constructor 。 full = false 。 rested = true 4. Should have getters/setters for all instance variables. 5. Should have a toString() method that just returns information about the object. Goldfinch -wingSpan: double +Goldfinch() +Goldfinch(int simID, Location I, wingSpan ws)
Expert Answer:
Answer rating: 100% (QA)
Locationjava Location class representing a point public class Location private int xCoord pr... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
see below questions and provide me adjusted coding by using my coding. I share my coding and test failure message at the end. 1. BST.java 2.BSTNode.java Binary Search Tree you will be coding the...
-
Imagine you are a member of your local school board. You wantan answer to the very simple question, Are students learning?What can you recommend to school principals to answer thequestion?
-
Sanchez Corporation runs two convenience stores, one in Connecticut and one in Rhode Island. Operating income for each store in 2017 is as follows: The equipment has a zero disposal value. In a...
-
Find the average value of the following functions on the given interval. Draw a graph of the function and indicate the average value. f(x) = cos 2x; [-]
-
An investment is guaranteed to have a unique value of IRR if which of the following is true? a. Alternating positive and negative cash flows b. An initial negative cash flow followed by all positive...
-
Watts Company makes various electronic products. The company is divided into a number of autonomous divisions that can either sell to internal units or sell externally. All divisions are located in...
-
Write a MATLAB program that asks the user to enter his results in four quizzes (q1,q2, q3, and q4) out of 100, and calculate the average value. Then print the output given in the Table below to the...
-
Based in Winnipeg, Manitoba, Defence Electronics Inc. (DEI) was founded to provide security systems, facilities controls and related services. DEI established a solid reputation for quality and the...
-
The elevation of the invert at Manhole 1 is 74.625'. The upward grade of the sewer is 1%. We wish to set a nail on a batter board 8 feet above the invert at Station 2+00. The back- sight at BMI whose...
-
Please create a PowerPoint of 5-8 slides that provide an overview of your progress on your final case review paper and upload this as an attachment. (1) You should have the company that you have...
-
Undertake research and list four sources of HR data and information which can be accessed and utilised when conducting a review of HR functions. Submit documentary evidence for each of the four...
-
Explain and evaluate economic policies that aim to reduce negative externalities, using an example of either a negative production externality or a negative consumption externality in your...
-
What does a cash flow statement indicate from the investors' point of view? Explain.
-
Read the article "A, 'Made in America' iPhone Would Cost $2,000, Studies Show". What is this article about? Why iPhone price could go sky high if it is all-American made? Between U.S and China, on...
-
A 200-g block is suspended by a light spring (spring constant 75 N/m) attached to a ball (of negligible mass) suspended by two light ropes. What are the tensions in the ropes? 30 50% Rope 1 Rope 2
-
Les has collected stamps in his spare time for years. He purchased many of his stamps at a price much lower than the current market value. Les recently lost his job as a carpenter. Since his wife...
-
Popeye Canning is contracted to receive daily 60,000 lb of ripe tomatoes at 7 cents per pound from which it produces canned tomato juice, tomato sauce, and tomato paste. The canned products are...
-
Determine the optimum solution for each of the following LPs by enumerating all the basic solutions. (a) Maximize z = 2x1 - 4x2 + 5x3 - 6x4 Subject to x1 + 4x2 - 2x3 + 8x4 2 - x1 + 2x2 + 3x3 + 4x4 ...
-
Consider the TOYCO model. (a) Suppose that any additional time for operation 1 beyond its current capacity of 430 minutes per day must be done on an overtime basis at $50 an hour. The hourly cost...
-
Provide an overview of the behavioral finance perspectives of risk.
-
Define the heuristic biases of representativeness, anchoring, and mental accounting.
-
List and explain some fundamental issues of behavioral finance.
Study smarter with the SolutionInn App