Reference no: EM132197699
Write the code to define the class Pet, Pet needs to implement Comparable and has attributes name (a string) and age (an integer), Assume that pets are compared using their age and their name (take advantage of the fact that Strings already have a compareTo method), with age being the primary (first) criteria.
Pet should have a single constructor that takes in the name and age as arguments.
Pet needs (to override) the toString method that returns "Name = x, age = y", where x and y are the name and age of the pet.
Pet should also override the equals method. So, you'll need are 0)
The proper class definition 1) the data, 2) a compareTo method, 3) an equals (overridden) method, 4) the constructors, and 5) the toString methods.
Do not write other methods or getters/setters.