Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Each student should do their own work, but may use Google or any other references, including asking questions of their classmates. This program must be

Each student should do their own work, but may use Google or any other references, including asking questions of their classmates. This program must be your work only. Programming assignments must be submitted in eCampus to receive credit. The Intelli-J project folder with its contents should be compressed into a single zip file and the zip file attached to the assignment submission. Programs must compile and run without errors to receive credit. Each assignment may be submitted up to three times to improve your grade.
Part 1:
Each of the following classes will be placed in a separate source file. Create the following artifacts:
Animal, with the String attributes name and breed.
Cat and Dog are subclasses of Animal.
AnimalI, an interface declaring two methods makeSound and whatAml that return strings.
Each of the three classes will implement the interface, have a constructor and getter methods for each attribute. I suggest using the Generate option from the Code dropdown menu to generate these "boilerplate" methods. Also, the Animal class needs a toString method which references the whatAml and makeSound methods. The Cat and Dog classes should NOT have toString methods.
Finally, a Main class (see below) that will create a Scanner object to read a text file (see example below) containing three fields, separated by commas, type, name, and breed. Depending upon the type (A, C or D), create an Animal or Cat or Dog object and store it in an Arraylist of animals.
After all records have been read, iterate through the Arraylist to print the animal using the tostring method.
Don't forget to close the text file.
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions