In this lab you will modify and/or extend your previous "Balls Animation" program to use multiple classes with inheritance. Please start with your previous lab (which you are free to modify as you wish), not the example program from me, although you may consult my example.

Here is a slightly cleaned up version of the example I cooked up in lecture. Note that this only has 2 types of balls: ExampleBallsInherit.zip

The requirements for using inheritance and the associated grading points are as follows:

  • Create a "base class" for your different ball types that is declared abstract and has at least one method declared abstract. Your various ball classes will inherit from this class, but the scene will not create any objects of this class directly.
  • Create at least 3 subclasses of your abstract base class for your different ball types. You can also inherit more than 2 levels if you want (have one subclass inherit from one of the other subclasses).
  • At least somewhere in the calling class for the objects (e.g. the Scene class), call all of the objects using the base class type ("polymorphism").
  • At least one of your subclasses (or all of them if you want) should call the super( ) constructor from its own constructor to help construct the object.
  • At least one subclass should override a method in the base class and replace it completely with a new implementation.
  • At least one subclass should override a method in the base class, and in the new implementation it should call the super version of the method, and then add additional code to extend the implementation of that method.
  • At least one subclass should add a method that is not in the base class, and the caller (e.g. the Scene class) should use the Java instanceof operator to determine when it is allowed to call that method, then use a type cast to call it using the subclass type.
  • Use the @Override annotation on all of your method overrides to get better compiler error checking.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.