Lab Project

In groups of three I would like you to solve p. 10.13 found on page 717 in the textbook. For this problem, I would only like the implementation of the two-dimensional world, so in essence you have the following:

                      Shape
                        ^
                        |
               TwoDimensionalShape
                ^       ^       ^
                |       |       |
             Circle  Square  Triangle
For this problem:

  1. Implement the above Shape hierarchy
  2. Each 2D shape has a getArea method
  3. Create an array of Shape * dynamically from an external datafile
  4. After reading in the data, output each shape's area and shape type
The datafile looks like the following:
ObjectName  ObjectData 
examples for each are:
Circle  x-coord  y-coord  radius
Square  upperLx-coord  upperLy-coord  lowerRx-coord  lowerRy-coord
Triangle pt1x-coord  pt1y-coord  pt2x-coord  pt2ycoord  pt3xcoord  pt3ycoord

Possible Sample Datafile

Triangle 2 3 4 1 6 3
Square 5 5 10 10 Square 1 1 2 2
Circle 15 15 2
Triangle 20 30 40 10 60 30