Question
Overview The exercise will create a program to keep track of the animals for sale in a pet store. Our pet store only sells mammals
Overview
The exercise will create a program to keep track of the animals for sale in a pet store. Our pet store only sells mammals specifically dogs, cats and rabbits. The program will have an interface for Mammal that can be implemented for our Cat, Dog and Rabbit classes. The implemented classes of Cat, Dog and Rabbit will be abstract classes, which will form the base class for concrete extended from those classes. For example, the Cat class will implement the Mammal interface. From there, we can have a specific type of cat such as a Persian that will be the concrete class. Someone who adopts an animal from our pet store would adopt a specific cat that is the breed of Persian.
Either the Mammal class or an implemented class will implement the Comparable
Specifications
The project will create an interface called Mammal that can be implemented for the types of animals that we sell in our pet shop cats, dogs and rabbits. The Mammal interface should have all of the method headers for attributes or actions that are shared commonly amongst all of the animals. There should be at least 3 methods in the Mammal interface. For example, all mammals must eat, so there may be a method for eating that when implemented, will update an attribute in the implemented animal class.
The program will have at least 3 abstract class that extend from Mammal that represent cats, dogs and rabbits. The abstract classes will be the base classes for the variety of specific animals in each category. The concrete animal classes will extend from one of the base classification abstract classes. Either the abstract classes or the concrete classes will implement the Comparable
The tester class, containing the main method, should be used to print the information stored and generated by the subclasses. Polymorphism should be used to create a data structure, such as an ArrayList or an array, to hold the objects that will be used to generate the output for the program. The user should be presented with a menu that will allow them to, at a minimum, see the animals available for adoption or view a specific animal in the list. The abstract base class should have at least 5 attributes for the base class. Attributes can include such things as breed, name, age or other information common to the concrete classes based on the abstract class. You have the flexibility to add as many attributes as you determine appropriate, as long as there are a minimum of 5 attributes in the base class. The program should have at least the 3 specified concrete animals with one of the concrete subclasses extending another subclass. For example, the abstract Cat class implements Mammal. The concrete class Siamese extends Cat. The concrete class Tabby_Pointed_Siamese extends Siamese, because a Tabby_Pointed_Siamese is-a Siamese, which is-a Cat.
The subclasses should use the private instance variables in the base classes rather than creating duplicate instance variables in the subclasses as appropriate. HINT: Remember, public getter and setter methods in the base classes will be inherited in the extended classes. The extended class should only have instance variables for the attributes not stored in the super() class. At least 2 of the 3 extended classes should have a minimum of one additional instance method not found in the base class and unique to the subclass. The subclasses should implement or inherit the compareTo() method as appropriate. The nature of the comparison is up to you. Also, the extended classes should override the default toString() method to print specific information about the object using any of the instance variables available.
The user should be presented with a menu of options for output. The output for this project should include the information stored in both the instance variables in the super() classes and any instance variables in the subclasses as well as the result of the comparison using the compareTo() method.
Expected Output:
The expected output should contain the contents of the instance variables for the base classes and the extended classes. The output should also contain the result of the use of compareTo() and the overridden toString(). The output should include all of the data stored in the instance variables in a way that makes sense to the user based on the menu options presented to the user.
Java Requirements
The program must contain the Mammal interface, the abstract base classes of Cat, Dog and Rabbit that implement Mammal and the subclasses that extend from the base classes.
- Have an interface called Mammal
- The Mammal class should have at least 3 methods
- There are at least 3 abstract classes extended from the Mammal class Cat, Dog and Rabbit
- The concrete animal classes extend from an abstract class
- At least one concrete class extends from another concrete class
- The abstract classes and concrete classes are created correctly including private instance variables and the constructor
- The abstract classes or concrete classes implement the Comparable
interface - The abstract classes or concrete classes implement have a compareTo() method
- The subclasses use private instance variables correctly and have at least 5 attributes.
- The tester class has a data structure that uses polymorphism to store objects
- The output includes a menu allowing the user to print the information stored in the instance variables in the super class and the subclasses, as well as the result of the comparison using the compareTo() method as appropriate
Once you have it working as expected upload the .java file to this assignment drop box. You must also submit a Word doc or text file containing the Java code. Assignments not containing both the Java code and the text or Word file will be assigned a 0 for a grade.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started