Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this program we will be using inheritance, abstract classes, the Comparable interface and writing to a file. You will also need to create a

In this program we will be using inheritance, abstract classes, the Comparable interface and writing to a file. You will also need to create a custom exception which you must use and catch.

Create an abstract class Animal. This class should contain instance variables as follows:

String name must be at least 1 character but not more than 10 characters.

int paws must be from 0 to 4

methods

abstract speak() returns a String

toString() returns name and number of paws

getters/setters

constructors as needed

Should implement the Comparable interface. Compare on the name of the animal

Create a Dog class that extends Animal

Implement the abstract speak method return Woof, woof!

Create a toString() method should print the type of animal add the Animal toString() and append the results of the speak method.

Create a Cat class that extends Animal

Implement the abstract method return Meow.

Create a toString() method should print the type of animal add the Animal toString() and append the results of the speak method.

Create an InvalidAnimalException which will be used if an invalid animal is entered.

Create an AnimalTester class.

Create an array of Animals at least 5 Animals.

Using a Random assignment Assign a mixture of Cats and Dogs to the array.

You will need a method to allow users to enter the name and number of paws. This cannot be static.

Write the original array to a file.

Sort the array.

Write the sorted array to the same file.

Read the file and print the results.

You must use your custom exception to tell the user if their entry is invalid.

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago

Question

To find integral of sin(logx) .

Answered: 1 week ago

Question

Recognize the four core purposes service environments fulfill.

Answered: 1 week ago

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago