Question: Can i get help with this java code please B: Programming Create a Pet class. Your class must use encapsulation (information hiding). Your Pet class

Can i get help with this java code please B: Programming CreateCan i get help with this java code please

B: Programming Create a Pet class. Your class must use encapsulation (information hiding). Your Pet class must not be a program. The state and behaviour of the class (and objects) is described as follows: A Pet object will have the following attributes: a name (String), birth year (int), type of pet (String such as "cat", "dog", "eel"), and a list of its children (array of Pet objects) A pet's birth year should never be able to be changed after it is set in the constructor Provide a constructor that takes a name, birth year and type of animal as input and initializes the Pet object. Each attribute should have a getter method. Provide a setter method only for the list of children (that should take an entire array of Pet objects as Add a method that returns the number of children a pet has. The method should be called numberOfChildren. C: Programming Create a Java program UsePet. Your program must have a method that takes a Pet object and a String as input and returns true if the pet has a child with the name as given by the string, and false otherwise Your program must create the following Pet object: Fluffy, a cat, who was born in 2012 She has two children: Igor, a cat, who was born in 2013 (who has no children) and Wei, an owl (who was adopted), who was born in 2014 (who has no children). Your program should then ask for user input (using a Scanner object) for a name. Using your method (from above), check if Fluffy has a child with the given name and output an appropriate message. yes, Fluffy has a child named Goran. or no, Fluffy does not have a child named Goran For example, if the user input was " Goran", the output should be one of Do not hardcode "fluffy" in the output message. It should print whatever name the Pet Your program should work correctly no matter what Pet object object in your program has. we initially create. Do not hardcode your solution for the Fluffy pet Do not create any UsePet objects in your program. Potentially Useful Things java.util.Scanner has a next O method that returns the next String token (word) from a given scanner object B: Programming Create a Pet class. Your class must use encapsulation (information hiding). Your Pet class must not be a program. The state and behaviour of the class (and objects) is described as follows: A Pet object will have the following attributes: a name (String), birth year (int), type of pet (String such as "cat", "dog", "eel"), and a list of its children (array of Pet objects) A pet's birth year should never be able to be changed after it is set in the constructor Provide a constructor that takes a name, birth year and type of animal as input and initializes the Pet object. Each attribute should have a getter method. Provide a setter method only for the list of children (that should take an entire array of Pet objects as Add a method that returns the number of children a pet has. The method should be called numberOfChildren. C: Programming Create a Java program UsePet. Your program must have a method that takes a Pet object and a String as input and returns true if the pet has a child with the name as given by the string, and false otherwise Your program must create the following Pet object: Fluffy, a cat, who was born in 2012 She has two children: Igor, a cat, who was born in 2013 (who has no children) and Wei, an owl (who was adopted), who was born in 2014 (who has no children). Your program should then ask for user input (using a Scanner object) for a name. Using your method (from above), check if Fluffy has a child with the given name and output an appropriate message. yes, Fluffy has a child named Goran. or no, Fluffy does not have a child named Goran For example, if the user input was " Goran", the output should be one of Do not hardcode "fluffy" in the output message. It should print whatever name the Pet Your program should work correctly no matter what Pet object object in your program has. we initially create. Do not hardcode your solution for the Fluffy pet Do not create any UsePet objects in your program. Potentially Useful Things java.util.Scanner has a next O method that returns the next String token (word) from a given scanner object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!