Question: a . have a Pet interface that exports abstract methods for the String name ( ) and int age ( ) of the pet. b

a. have a Pet interface that exports abstract methods for the String name() and int age() of the pet.
b. create a Lizard and Dog class that both implement the Pet interface.
c. make Pet sortable/comparable to other Pet objects, i.e.: interface Pet extends Comparable {..}
(NB: Comparable is a standard java interface one can use to "tag" you custom object/type as being 'naturally sortable' via the java collections framework)
d. implement the required compareTo(..) method -- we'll say for any two pets p1, p2, that p1 'comes before' p2 if p1.age()< p2.age()
e. add a PetRepo class that encapsulates a list of Pet objects currently in the pet shop. This class should have the following public API:
-void sort() method that sorts the underlying collection of pets using Collections.sort(...)
-void add(Pet p) takes a pet and adds it to the list of Pet objects
-void clear() empties out the pets list
-String toString() override toString to render to the toString for each pet on its own line.
Next, add a package for the view and the event handling logic. Follow the approach demonstrated and worked so far in class.

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 Programming Questions!