Question: First, create a class called Dog that implements the Comparable interface. Dog will contain a member variable to hold a name, a constructor that sets

First, create a class called Dog that implements the Comparable interface. Dog will contain a member variable to hold a name, a constructor that sets up the name, and three methods (getName, compareTo, toString). getName returns the member variable, compareTo works as defined by the Comparable interface, and toString returns the name neatly formatted. Second, you'll compare Dogs by their names. Include a main method in Dog that asks the user to input ten names and generates ten Dog objects. A blank name should not be used to create an object. Using the compareTo method, determine first and last dog among them and print them. Do not simply sort the Dog data.

Sample Output: First, create a class called Dog that implements the Comparable interface. Dog Thank you!

output SER200 HW11 (run) Variables Action Items run Please enter the dog's name or a blank line to quit Fido Please enter the dog's name or a blank line to quit Skippy Please enter the dog's name or a blank line to quit Fuzzy Please enter the dog's name or a blank line to quit Bailey please enter the dog's name or a blank line to quit Max Please enter the dog's name or a blank line to quit First Dog [name Bailey] Last Dog [name-Skippyl

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!