Answered You can hire a professional tutor to get the answer.

QUESTION

Implement the Pet_Lastname class. Data Fields - Instance variables / static variables / constants A pet has: id , name , price, and an adoption...

A.        Implement the Pet_Lastname class.

Data Fields - Instance variables / static variables / constants

A pet has:

id, name, price, and an adoption status. Have the adoption status as Boolean variable (if adapted it will be set to true, set to false otherwise. You can name the variable adopted). For these variables you must maintain data encapsulation, pick the correct modifier.

The pet also has a type and an age. age and type (for example dog or lizard) are NOT private.

----------

Declare a variable that will keep track of the current number of new created pet objects and have it updated in the constructor.

Declare a variable that will represent the current number of checked in pets (name is num_in). Initialize the variable to 16.

Declare a variable that will represent the current number of adopted pets (name is

num_adopted).

----------

Declare a constant that represents the capacity of the pet store and initialize it to 20 (it is a constant).

Constructors

Write constructors for the Pet_Lastname class:

1.        a constructor that takes as arguments id, name, and initialize the price to 50, age to 1.

2.        a constructor that takes no arguments and initializes the variables (id, name, price, adopted, type, age) to 1000, Doe, 10, false, unknown, 1.

3.        a constructor that takes as arguments a specific id, name, adoption status, type And age and initialize the variables to these values.

Setters and Getters

Create setters and getters for all private instance variables. Enforce the data integrity by making sure that the price is in the range [0 to 200].

Methods -  Give the complete signature for each method and implement each method based on its description.

introduceMyself() will print a hello message together with the pet's name and type.

checkIn() If the store is up to its capacity, it will display a message that a new pet cannot check in, otherwise it will update the number of checked in pets.

medicalRecord( ) This method will generate a random number between 0 and 10. If the number is <6, the method will return false, otherwise it will return true.

Note: true means that the pet has its medical record on file, false means that it doesn't have it.

This information will be used later on in a different method.

readyAdaption() will return a boolean. It will call medicalRecord(); if the pet has its medical record on file, the pet is ready to be adopted. adopted variable is set to true and the method will return true. The method should display an informative message and, when necessary, update the amount of number of ready to be adopted pets.

checkOut()will call readyAdaption() method and if the pet is ready for adoption it will decrease the number of current checked in pets. It will also display an informative message that will let know if the pets checked out or not. At least the name should be specified.

petInfo() will display the pet's information (the values of all the instance variables). storeInfo() will display the number of checked in pets and the number of adopted pets at that

specific moment. This method should be a static method since it doesn't depend on a specific

pet.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question