Question: 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

 B: Programming Create a Pet class. Your class must use encapsulation

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 input) Add a method that returns the number of children a pet has. The method should be called numberOf Children

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!