Question: Location Class This class encapsulates a point on a simulation map. You should adhere to the following specifications for this object: 1. *Coord and

Location Class This class encapsulates a point on a simulation map. Youshould adhere to the following specifications for this object: 1. *Coord andyCoord cannot be less than zero. Need to catch and handle anInvalidCoordinateException for this object. 2. The empty-argument constructor initializes xCoord and yCoordto zero. 3. The preferred constructor initializes xCoord and yCoord with the

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 < > 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. < > Flyable +fly(Location I):void < > < > 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[] < > 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) < > < > < > 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)

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Locationjava Location class representing a point public class Location private int xCoord pr... 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!