Create three public classes one named app one named pet and


1. Create three public classes: one named App, one named Pet and one named PetOwner. The App class has a static void main method that performs all the actions for the Deliverable A and Deliverable B requirements.

2. The Pet Owner class must have private fields for the following state information. Create a private field to represent each of these states, each field should default to null, zero, or false values as appropriate: 

o Owner First Name (a simple string for storing the first name of the owner)

o Owner Last Name (a simple string for storing the first name of the owner)

o Owner Address (a simple string for storing the mailing address in one line)

o An integer value for the number of pets currently owned by this owner

o AnintegervalueforthemaximumnumberofpetsthattheownerhasEVERowned (now or in the past) 

3. The PetOwner class must have public accessor methods for accessing the following state information: 

o Owner First Name (a simple string for storing the first name of the owner) o Owner Last Name (a simple string for storing the first name of the owner) o Owner Address (a simple string for storing the mailing address in one line) o A boolean value representing whether the owner currently has a pet or not o An integer value for the number of pets currently owned by this owner 

o A boolean value whether the owner has ever owned a pet (either now or in the past) 

o AnintegervalueforthemaximumnumberofpetsthattheownerhasEVERowned (now or in the past) 

4. The PetOwner class must have public mutator methods for modifying the following state information: 

o Owner First Name (a simple string for storing the first name of the owner) o Owner Last Name (a simple string for storing the first name of the owner) o Owner Address (a simple string for storing the mailing address in one line) 

5. The PetOwner class must maintain all the state information (as mentioned above). In other words, the program must set these values correctly; but this can be done via public mutators, public helpers, or and other methods described in this document: 

For example: when the first pet is added, the pet owner must update the state to reflect that there now one pet currently owned, and also update the other state information as well. Contrariwise, if the last pet is removed, the number of pets currently owned would be zero, the pet owner would know that they do not currently own any pets, but also that they had owned one pet in the past. 

6. The PetOwner must also be capable of storing a reference to each of the actual Pets currently owned by this owner (if there are any). Each Pet owned by this PetOwner will be added by invoking a public method declared within PetOwner class, whose signature is public void addPet(Pet p) throws Exception Each Pet Owner object can own any number from zero (0) up to five (5) pets. 

You can define other private state fields and methods to implement this as you see fit. if 5 pets are already owned, an exception with a message like this must be thrown: "Unable to add Pet: n because too many pets already owned by PetOwner: "(replace with the value of the pet owner's actual first name) if the p parameter is null, an exception with a message like this must be thrown: "Unable to add Pet because it is null"

7. A PetOwner object must be able to print all its state information including the details for all pets currently owned with a public method whose signature is public void dump(). The dump method should output the name of a field followed by its value on a single line in a readable fashion. For example, if we had a PetOwner object named "George Jetson" who lived at "123 Milky way" and owned one Pet (a dog named "Astro" who eats "Milky-Way Bones") we would see output something like this: 

  • Owner First Name : George
  • Owner Last Name : Jetson
  • Owner Address : 123 Milky way
  • Owner Number of Current Pets : 1
  • Owner Currently Has a Pet : true
  • Owner Has Ever Owned a Pet : true
  • Owner Maximum Number of Current-and-Past Pets: 1 Pet Type: dog 
  • Pet Name: Astro
  • Pet Food: Milky-Way Bones 

8. The Pet class must have private fields with public accessor and mutator methods for the following state information: (again all fields should default to null values) o Pet Type (a string describing the type of pet that it is) o Pet Name (a string containing the pet's name)o Pet Food (a string describing what the pet likes to eat) 

9. The Pet class must be able to print all its state information with a public method whose signature is public void dump() (similar formatting / readability considerations). 

10. Create a runable program that meets the running requirements and output, the technical requirements for Deliverable A, and is capable of running the following execution requirements (invoked directly or indirectly from the main method in your App class). Execution Requirements for Deliverable A:

1st. Create a pet object representing Puff, a dragon, who eats Knights of the Round Table. 

2nd. Create pet owner object representing Jackie Paper, who lives at 123 Main Street, and currently owns Puff, the dragon. 

3rd. Create a pet object representing Tux, a penguin, who eats Fish.

4th. Use the addPet method to modify the state of the pet owner object representing Jackie 

Paper, to indicate that he is now also the owner of Tux the penguin. 

5th. Invoke the dump method for the pet owner object representing Jackie Paper 

6th. Create a pet object representing Dino, a dinosaur, who eats Brontosaurus steaks. 

7th. Create pet owner object representing Wilma Flintstone, who lives at 456 Bedrock Road, and currently owns Dino, the dinosaur. 

8th. Create a pet object representing Barney, a dinosaur, who eats Plants.

9th. Use the addPet method to modify the state of the pet owner object representing Jackie 

Paper, to indicate that he is now also the owner of Barney the dinosaur.

10th. Invoke the dump method for the pet owner object representing Jackie Paper.

11th. Invoke the dump method for the pet owner object representing Wilma Flintstone. 

Deliverable B:

Technical Requirements for Deliverable B: 

a) Add code to the PetOwner class capable of returning a pet object based upon the type and name details for the pet (if it is currently owned) with a public method whose signature is: 

public Pet findPet(String type, String name) throws Exception 

If the type parameter is null, then an exception with a message like this must be thrown: "Unable to findPet because type is null." 

If the type parameter is not null, but the name parameter is null, then an exception with a message like this must be thrown:

"Unable to findPet because name is null." 

If there is no pet owned the method should return null. 

If none of the pets owned have the same type and same name as specified in the parameters, the method should return null. Note: when searching for the pet object, the type and name should be compared case-sensitively. For example name "Astro" (with uppercase A) will not match a pet whose name is "astro" (with lowercase a). 

If a pet with the same type and name as specified is owned, return a reference to it. If there are multiple pets with the same type and name as those specified, return a reference to one of them (there is no specified precedence order). 

b) Add code to make the PetOwner capable of removing a pet object (if it is currently owned) with a public method whose signature is 

public void removePet(Pet p) throws Exception 

If the pet parameter is null, then an exception with a message like this must be thrown: "Unable to remove pet because it is null." 

If the pet does not exist, then an exception with a message like this must be thrown:

"Unable to remove pet because PetOwner: does not own a pet named ." (replace the place holders with actual state values) 

If the specified pet is owned by this owner, then this method should update the pet owner object's state to reflect the removal of the pet (e.g. updating the number of pets currently owned, etc.). 

c) Create a runable program that meets the running requirements and output, the technical requirements for Deliverable B, and is capable of running the following execution requirements (invoked directly or indirectly from the main method in your App class). 

Execution Requirements for Deliverable B:

12th. Continuing from the 11th step of Deliverable A, find a pet (using the findPet method) of type dinosaur with name Dino from the pet owner object representing Wilma Flintstone. 

13th. Invoke the dump method on the pet returned from the 12th step. 

14th. Use the removePet method to modify the state of the pet owner object representing Wilma Flintstone, to indicate that she is no longer the owner of the pet returned from the 12th step. 

15th. Use the removePet method to modify the state of the pet owner object representing Jackie Paper, to indicate that he is no longer the owner of the pet returned from the 12th step. 

16th. Use the addPet method to modify the state of the pet owner object representing Jackie Paper, to indicate that he is now also the owner of the pet returned from the 12th step. 

17th. Invoke the dump method for the pet owner object representing Jackie Paper.

18th. Invoke the dump method for the pet owner object representing Wilma Flintstone. 

19th. Find a pet of type dragon with name Puff from the pet owner object representing Jackie Paper. 

20th. Modify the state of the pet object returned from the 19th step, so that he now eats Knights in shining armor. 

21st. Invoke the dump method for the pet owner object representing Jackie Paper.

22nd. Find a pet of type penguin with name Tux (using the findPet method) from the pet owner object representing Jackie Paper. 

23rd. Invoke the dump method on the pet returned from the 22nd step. 

24th. Use the removePet method to modify the state of the pet owner object representing Jackie Paper, to indicate that he is no longer the owner of the pet returned from the 22nd step. 

25th. Use the addPet method to modify the state of the pet owner object representing Wilma Flintstone, to indicate that she is now also the owner of the pet returned from the 22nd step. 

26th. Find a pet of type dinosaur with name Barney (using the findPet method) from the pet owner object representing Wilma Flintstone. 

27th. Invoke the dump method on the pet returned from the 26th step. 

28th. Use the removePet method to modify the state of the pet owner object representing Wilma Flintstone, to indicate that she is no longer the owner of the pet returned from the 26th step. 

29th. Invoke the dump method for the pet owner object representing Jackie Paper.

30th. Invoke the dump method for the pet owner object representing Wilma Flintstone.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create three public classes one named app one named pet and
Reference No:- TGS01469539

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)