Question: Instructions Modify the Cat class lab to make all data private, include setters and getters, and create two different Cat objects in a separate Main

 Instructions Modify the Cat class lab to make all data private,

Instructions Modify the Cat class lab to make all data private, include setters and getters, and create two different Cat objects in a separate Main class. In the Main class, do the following: - Create a cat object with reference variable "Garfield" - Create another cat object with reference variable "Crookshanks" - Set Garfield's age to 7 - Set Crookshanks' age to 11 - Check if Garfield and Crookshank are "old" (older than 10 years old) - Check if Garfield and Crookshank are the same age. Please submit .java or zip file (not just screenshot) From previous lab: - Create a class named 'Cat'. - Add an integer field named 'age' to class Cat. - Add a method 'getAge()' to class Cat that returns the current value of the field 'age'. - Add a method 'void setAge(int newAge)' to class Cat that sets the field 'age' to a new value. - Add a method 'void setAge(String newAge)' to class Cat that sets the int field 'age' to a new value. Use Integer.parselnt("some string") to convert a string to an int. - Add a method 'boolean isOld()' to class Cat that returns true if the cat's age is greater than 10. - Add a method 'boolean sameAge(Cat anotherCat)' to the class Cat that returns true if the other cat is the same age as this instance. - Add a method 'void birthday()' that increases the int field age by 1

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!