How can we improve our current class structure?
We are going to create a second “Generation” of classes and will denote this change by appending a ‘2’ to the names of all classes in this “generation”
Class: Polygon2 (superclass of Triangle2, Rectangle2) Polygon2
Constructor
public Polygon2(int _col, double _width, double _height, int _sides)
instance Variables
- private int color;
- private int numSides
- protected double width;
- protected double height
Methods
- public int getColor()
- public double getWidth()
- public double getHeight()
Class: Rectangle2 extends Polygon2 Rectangle2
instance Variables
None needed (see superclass)
Accesor Methods //override each of the superclass
- public double getArea(); //returns the area of the triangle
Class: RightTriangle2 extends Polygon2 RightTriangle2
instance Variables
None needed (see superclass)
Accesor Methods //override each of the superclass
- public double getArea(); //returns the area of the triangle
- public double getHypotenuse()
InteractiveMath2 InteractiveMath2