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

  Create an overloaded constructor that provides values

Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and -).

  Create a virtual world application

Create a Virtual World application as your final project. This Virtual World will have several objects including a MyClone object and another object of your choice.

  Object-oriented gui drawing editor

A simple object-oriented GUI drawing editor that allows a user to create, move and erase rectangles, squares, circles and lines in an interactive graphics. How can I draw move erase rectangles, squares, circles and lines in GUI/java.

  Implement the getperimeter that returns the perimeter

Design a class named Triangle that extends GeometricObject. The class contains three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle. Implement the getPerimeter that returns the perim..

  Class to initialize values

Create a constructor that allows a user of the class to initialize values. Also create a method named SetJustSold()(Hint ++) that increments the number of hot dogs the stand has sold by one and should also increase the TotalSold by one

  Create a fully complete educational mobile game

You will individually create a fully complete educational (school-age) mobile game using mobile web design skills. You will submit your completed application's project folder as a zip file

  Simple java application that uses the string

Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.

  Develop a java program given the width, length and depth

Write the source code for each class in a separate file which must have the same name as the class name together with the extension .java. Remember also that by convention, class names commence with a capital letter.

  Design and implement a set of classes and interfaces and

design and implement a set of classes and interfaces and use them to evaluate the rtas resource requirements.nbspyour

  System.out.println statement

Display the value stored in num4 with the label "The result of the constant const1 multiplied by the constant const2 is " - Please use the precisely same character strings provided to you below in your System.out.println statements.

  Write a on the popularity of java

Write a 4-5-page research-oriented paper in APA format that focuses on the "Popularity of Java". The paper must cite at least 5 references, not including the textbook or the Bible.

  Declare a string variable named empty

Declare a string variable named empty, and initialize it to the empty string.

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