Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: image text in transcribed 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions