The Case for Abstract Classes and Methods

shape_abstract_class

 

Shape

download-bttn Shape Class

Constructor 

  • public Shape( int _col)

instance Variables

  • protected int color

Accesor Methods

  • public abstract double getArea(); //returns the area of the triangle
  • public int getColor()
  • public void render()  { System.out.println(“rendering shape” ) ; }

 

 


Now, let’s refactor our class relationships to represent our new Iheritance Tree

  1. refactor all subclasses to reflect new class hierarchy
  2. Update our new InteractiveMath class –InteractiveMath3