Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with my JAVA homework pleeeeease, I am really confused on how to start it. Your program must do the following in order

Please help me with my JAVA homework pleeeeease, I am really confused on how to start it.

Your program must do the following in order to receive full credit on this assignment. 1. Create a new public class called Pet in its own file. a. Remember that class and file name must match. 2. Create three private instance variables. a. The name of the pet. b. The age of the pet. c. Whether the pet is adopted or not. 3. Create a default constructor for the Pet class. a. Remember that a default constructor takes no arguments and assigns meaningless values to the instance variables. 4. Create a second constructor for Pet that takes a name and age as arguments. a. Assign these values to the instance variables. b. Pets always start off un-adopted. 5. Provide a get and set for the name instance variable. 6. Provide a get for age, but instead of a regular set create a method that increases age by 1. a. Keep in mind that this age increase method will need to be public. 7. Provide a get for the adopted variable and instead of a set provide a public method which sets this adoption variable to true. a. Note: This is the last thing you will do in Pet. The rest of these steps are done in your main program file. 8. Create a Scanner object that will be visible to all methods in Assignment5. a. This object will need a particular modifier. What is it? 9. Create a private static String method which prints out the main menu of the program. It then accepts a String from the user and returns their choice. The commands to list are as follows. a. List the pets in the store. b. Age up the pets. c. Add a new pet. d. Adopt a pet. e. Quit. i. Your method must verify that the user typed in a valid input before returning the input. 10. Within the programs main method, create two local pet objects. a. The first is named Fido and is 3 years old. b. The second is named Furball and is 1 year old. 11. Create a third local pet object, but do not create a new pet object yet. a. This represents the pet that the user can add later. b. What should this be initialized as? i. Theres a special value for objects that dont exist yet. 12. Print out a welcome message, and then call your main menu method to display the menu and get the users first input. 13. Create a while loop that will run until the user types in the exit command at the menu. a. After the loop print a goodbye message. 14. Within the loop determine which menu choice the user picked and do the appropriate action. The different possible actions are defined in the following steps. a. Dont forget to take a new input from the user after youve processed their choice. 15. If the user chose to print the pets, print out the information about each pet. a. For example: Fido is 3 years old and is not adopted.. b. If the pet is only 1 year old, it should say year instead of years. c. If the pet is adopted, it should say they are adopted instead. d. See example inputs. e. Be careful to not try to print the third pet if it hasnt been added yet! 16. If the user chose to make all the pets one year older, invoke your method to age the pet up by one year on all the pet objects. a. Again, be careful about the third pet! 17. If the user chose to add a new pet, accept a name and age from the user and create a new pet object for the third pet. a. If there already is a third pet, print an error message instead. b. You do not have to validate the name or age in any way. You can assume the user types in valid values. 18. Finally, if the user chose to adopt a pet, ask them to type in the number of the pet they want. a. This number corresponds with the order in which they are printed out. b. Verify that they typed in a valid number for an existing pet. i. This means if pet three hasnt been added then 3 is invalid. c. Check if the pet is already adopted and print a message if it is already adopted. d. Otherwise, change its status to adopted.

one of the out put:

welcome to the pet store!

Type the letter to make your selection.

A.List the pets in the store.

B.Age up the pets.

C.Add a new pets.

D.Adopt a pet.

E.Quit.

choose:A

Fido is 3 years old and is not adopted.

Furball is 1 year old and is not adopted.

Type the letter to make your selection.

A.List the pets in the store.

B.Age up the pets.

C.Add a new pets.

D.Adopt a pet.

E.Quit.

E.

Have a good day!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago