Create a private field to represent each of these states

Assignment Help JAVA Programming
Reference no: EM131091489

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: <pet-name>n because too many pets already owned by PetOwner: <first-name>"(replace <first-name> 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: <first-name> does not own a pet <pet-type> named <pet-name>." (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.

Reference no: EM131091489

Questions Cloud

Benefits of online education in arizona state university : A Short report on Benefits of Online Education in Arizona State University
Determining the company own workers : What is the practice of contracting with another company to do a specific job that would otherwise be done by a company's own workers.
Ratio of a good money price : What is the the ratio of a good's money price to the price of the next best alternative good (is its opportunity cost)?
Macroeconomists to rethink monetary and fiscal policies : The financial crisis of 2008 caused macroeconomists to rethink monetary and fiscal policies. Economists, financial experts, and government policy makers are victims of what former Fed chairman Alan Greenspan called a "once in a century credit tsun..
Create a private field to represent each of these states : 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.
Describe a procedure to enable you to make an estimate : Choose ONE of the scenarios below, then design an experiment and describe a procedure to enable you to make an estimate of the average speed. Your description should include the materials you would need and how you would use them to collect the da..
Improve working conditions : What is the organization of workers that tries to improve working conditions, wages, and benefits for its members.
Supply of workers meet the demand : What is the wage rate, or price of labor services, that is set when the supply of workers meet the demand for workers in the labor market.
Calculate a rating similar to iso-ppc : For this assignment, you will research your community, and calculate a rating similar to ISO/PPC though NOT using an ISO/PPC rating scale. For this project, you will be using our own rating scale, which is found in the grid below. (see attachment)

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a java program that will play connect four

Write a java program that will play connect four - Must be a simple program no applets, jframes.

  Need a console program

Need a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed).

  Write a gui program that maintains a set of contacts

Write a GUI program that maintains a set of contacts. Each contact has name, address, and a list of phone numbers. This contacts should be be stored in a HashMap

  Produce a java implementation of the gui

For your Assignment 2 Part 1 submission you are required to produce a Java implementation of the GUI for the Agriculture image viewer component of your overall Agriculture File Storing and Management (FSM) System.

  Write a program that bounces a blue ball inside a jpanel

Write a program that bounces a blue ball inside a JPanel. The ball should begin moving with a mousePressed event. When the ball hits the edge of the JPanel, it should bounce off the edge and continue in the opposite direction. The ball should be upda..

  Demonstrate your knowledge in a pragmatic way

Summarize everything that we have addressed in the XML Applications course, and provide a mechanism to demonstrate your knowledge in a pragmatic way.

  Write a blog article for a codingtechnical community

write a blog article for a codingtechnical community blog.the theme is general c or java. choose any subject under this

  Explain how cookies are used to implement sessions

Describe a set of four methods that a queue would need to implement using a circular array and show the Java code to implement them if using an implementation given the outline definition below. Do not use any methods of the Collection classes.

  Write a java program to accept integer values

Write an algorithm, draw a flow chart and write a java program to accept integer values from keyboard and will find and print the minimum, maximum, summation and average of entered numbers when the number entered from keyboard is smaller than 1

  Which of these are problem-solving strategies

The strategy of removing components to return a computer back to a basic configuration is designed to eliminate variables that may make a computer problem more difficult to solve.

  What would be an incorrect way of writing this equation

Jim develops 5 Java applications a year. Joe develops 10 Java applications a year. Jim gets paid $5000.00 per application, but Joe gets paid $10000.00 per application.

  These test scores into an array and computes:

Write a program that reads these test scores into an array and computes:Sum of the test scores after dropping the minimum test scoreAverage of the test scores

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd