Lab 3: Using Abstract Classes & Methods
Due dates: This is a one week lab, so it will be due
October 9.
The knowledge needed to write this program will be tested on the exam on Friday, so
you should get as much of this done before the exam as you can. I think most of you
should be able to finish it in the lab. If you do, demo it today, if not demo it next Monday,
October 9
- Problem: You will write a superclass Shape, and three subclasses that inherit
from Shape. You will also need a driver to test your class hierarchy.
- Class Shape should include:
- abstract methods: computerArea, computePerimeter;
- constructor(s),
- it should also include a method toString (you decide whether it should
be abstract or not), and
- any other methods and instance variables you think appropriate.
- Three subclasses: Rectangle, Circle, and Triangle that inherit from class Shape.
- Include
any instance variables and methods you think appropriate.
- Write a driver to test your Shape class hierarchy.
- Be sure to use inheritance to do this problem. Do NOT hav a lot of if statemtments
testing whether the shape is a triangle, circle or rectangle.