Create a Class Pet with the following data members Identification: String species : String (e.g. cat, dog, fish etc) breed: String Age (in days): int Weight: float Dead: boolean 1. Provide a constructor with parameters for all instance variables. 2. Provide getters for all and setters for only breed, and weight 3. Provide a method growOld() that increases the age of the pet by one day. A dead pet wont grow old 4. Provide a method growHealthy(float w) that increases the weight of the pet by the given amount w. A dead pet cannot grow healthy. 5. Provide a method fallSick(float w) that reduces the weight of the pet by the given amount. The least weight a pet can have is 0 which will mean that the pet has died. If the value of weigh is 10 kg and the method is called with an argument of 11 kg then you will set it to 0 and set the dead to an appropriate value to mark the death of the pet 6. Provide a toString method that shows an appropriate well formatted string represntation of a pet object Build a class PetShop with the following data members Name: String Address: String Inventory: ArrayList 1. Provide constructor and do appropriate initialization 2. Provide a method addPet(Pet p) that adds the pet object p to the inventory 3. Provide a method Pet getPetByID(String id) that searches in the inventory for the given pet and returns its instance 4. Provide a method boolean isThePetDead(String id) that searches for the pet with given id in the inventory and returns a true if the pet is dead or false othewise. 5. Provide the toString method that gives all details about the shop and the inventory.
Create a Class Pet with the following data members
- Identification: String
- species : String (e.g. cat, dog, fish etc)
- breed: String
- Age (in days): int
- Weight: float
- Dead: boolean
1. Provide a constructor with parameters for all instance variables.
2. Provide getters for all and setters for only breed, and weight
3. Provide a method growOld() that increases the age of the pet by one day. A dead pet wont grow old
4. Provide a method growHealthy(float w) that increases the weight of the pet by the given amount w. A dead pet cannot grow healthy.
5. Provide a method fallSick(float w) that reduces the weight of the pet by the given amount. The least weight a pet can have is 0 which will mean that the pet has died. If the value of weigh is 10 kg and the method is called with an argument of 11 kg then you will set it to 0 and set the dead to an appropriate value to mark the death of the pet
6. Provide a toString method that shows an appropriate well formatted string represntation of a pet object
Build a class PetShop with the following data members
- Name: String
- Address: String
- Inventory: ArrayList<Pet>
1. Provide constructor and do appropriate initialization
2. Provide a method addPet(Pet p) that adds the pet object p to the inventory
3. Provide a method Pet getPetByID(String id) that searches in the inventory for the given pet and returns its instance
4. Provide a method boolean isThePetDead(String id) that searches for the pet with given id in the inventory and returns a true if the pet is dead or false othewise.
5. Provide the toString method that gives all details about the shop and the inventory.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images