Question: please help me with this prob!!! thanks! Part 1: Pet and PetTester: Write the Java code for a Pet class which matches the following description.
Part 1: Pet and PetTester: Write the Java code for a Pet class which matches the following description. Your class should have the following instance variable (pick the best type for each field): name. The name field holds the name of the Pet animal. The animal field holds the type of animal that a pet is. Example values are "Dog". "Cat", and "Bird" eats. The eats field describes the type of food that the animal makes. Example values are "kibble", "pellets", and "fish" The Pet class should have the following methods Constructor which has no arguments. It should initialize name to "None", animal to "", and eats to " SetName. The setName method stores a value in the name instance field setAnimal. The setAnimal method stores a value in the animal instance field setEats. The setEats method stores a value in the eats instance field getName. The getName method returns the value of the name instance field getAnimal. The getAnimal method returns the value of the animal instance field getEats. The getEats method returns the value of the eats instance field public String toString() This method should display the contents of each the fields in a nice format NOTE: There should not be a main method in the Pet class! Write the Java code for a PetTester class which matches the following description: Should contain a main method which does the following Constructs five different Pet objects. Use the set methods to store a value in the name, animal, and eats fields for each object. Display the contents of the object
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
