Professional Documents
Culture Documents
Assignment 2
1. Create an abstract base class, Ball. The single constructor requires a String to indicate the type of ball, which then is stored in an instance variable. The instance method getType(), returns a new String containing the type of ball. The class declares an abstract method play () which returns void. 2. Create an abstract class Bounceable which inherits from Ball. Bounceable has a single abstract method, bounce () which returns a String. There are no instance variables. 3. Create two concrete classes Baseball and Bowlingball which inherit from Ball. No instance variables or additional methods are required. Only implementation of any inherited abstract methods is required. 4. Create two concrete classes Tennisball and Basketball which inherit from Bounceable. No instance variables or additonal methods are required. Only implementation of any inherited abstract methods is required. 5. Create a PolyTest class with main that must use above mentioned classes and methods. 6. Draw class diagram for above.
Note: Comment your program appropriately. Use lower case camel, naming convention.
Page 1