Objective: Design, implement, and use classes and objects with polymorphism For this project, you will create an application for a zoo.  You can earn up to 5 points extra credit if you create a  JavaFX or Swing application for this project. You will need to create a class that implements the iAnimal interface as described in the discussion Zoo Animals and download at least one class by a fellow classmate for a different animal than your own from that discussion.  Modify the animal classes that you will use for this project so they implement Java's comparable (Links to an external site.) or comparator interface. (Links to an external site.) You will also need a Foothill (Main) Class that will provide a user interface for this application.  This can be a console-based interface or a JavaFX or Swing interface (you choose).  If you use JavaFX or Swing, you will need input boxes, at least one button with a click event to get the extra credit.  Based on user interaction, you will need to perform the tasks listed below.  These tasks can be performed in one or more methods as needed. The Foothill (Main) class should have one or more methods that handle these tasks: Create a new instance (object) of each of the animal classes and pass the user input as arguments to the object's mutator methods to set the private instance data for the appropriate animal class. Create an ArrayList of type iAnimal and add the new instance created in task 1 to the ArrayList.  Before adding the instance to the ArrayList you must: Call the compareTo method (see Java's comparable (Links to an external site.) or comparator interface. (Links to an external site.)) (Links to an external site.)  for the new animal's instance to compare that new instance to each of the instances already in the ArrayList (use a loop or recursion for this). If the ArrayList is empty, or if none of the instances are identical to the new instance, insert the new instance into the ArrayList. If the new instance is identical to any of the instances already in the ArrayList, display an error message and do not insert the new instance. When testing, add multiple instances of your animal's class and multiple instances of the class you borrowed from the discussion to the ArrayList as described above.  Because you are working with more than one class, you can decide how to determine which class to use based on user input, but the goal is to create an instance of the class that matches the type of animal entered by the user. Use a loop to iterate through the ArrayList and display all of the data for each instance in the ArrayList using accessor or ToString methods. Feel free to add whatever you need for testing purposes.  You can also make changes to your classmate's class as needed.  You do not need to include the output with your submission, but please add a comment to let me know which type of application you selected (console, Swing or JavaFX).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Objective: Design, implement, and use classes and objects with polymorphism

For this project, you will create an application for a zoo.  You can earn up to 5 points extra credit if you create a  JavaFX or Swing application for this project.

You will need to create a class that implements the iAnimal interface as described in the discussion Zoo Animals and download at least one class by a fellow classmate for a different animal than your own from that discussion.  Modify the animal classes that you will use for this project so they implement Java's comparable (Links to an external site.) or comparator interface. (Links to an external site.)

You will also need a Foothill (Main) Class that will provide a user interface for this application.  This can be a console-based interface or a JavaFX or Swing interface (you choose).  If you use JavaFX or Swing, you will need input boxes, at least one button with a click event to get the extra credit.  Based on user interaction, you will need to perform the tasks listed below.  These tasks can be performed in one or more methods as needed.

The Foothill (Main) class should have one or more methods that handle these tasks:

  1. Create a new instance (object) of each of the animal classes and pass the user input as arguments to the object's mutator methods to set the private instance data for the appropriate animal class.
  2. Create an ArrayList of type iAnimal and add the new instance created in task 1 to the ArrayList.  Before adding the instance to the ArrayList you must:
    • Call the compareTo method (see Java's comparable (Links to an external site.) or comparator interface. (Links to an external site.)) (Links to an external site.)  for the new animal's instance to compare that new instance to each of the instances already in the ArrayList (use a loop or recursion for this).
    • If the ArrayList is empty, or if none of the instances are identical to the new instance, insert the new instance into the ArrayList.
    • If the new instance is identical to any of the instances already in the ArrayList, display an error message and do not insert the new instance.
  3. When testing, add multiple instances of your animal's class and multiple instances of the class you borrowed from the discussion to the ArrayList as described above.  Because you are working with more than one class, you can decide how to determine which class to use based on user input, but the goal is to create an instance of the class that matches the type of animal entered by the user.
  4. Use a loop to iterate through the ArrayList and display all of the data for each instance in the ArrayList using accessor or ToString methods.

Feel free to add whatever you need for testing purposes.  You can also make changes to your classmate's class as needed.  You do not need to include the output with your submission, but please add a comment to let me know which type of application you selected (console, Swing or JavaFX).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education