CSCI-15 Polymorphism Assignment #8 (50 points) due 5/16/16

advertisement
CSCI-15 Polymorphism Assignment #8 (50 points) due 5/16/16
Modify your inheritance problem's classes to use virtual area and perimeter methods and
allow polymorphism. Write a client program that creates the various shape objects as
you did in the original assignment. Then, create an array of pointers to Quadrilaterals
containing the addresses of the various shapes you defined in ascending order by type,
Quadrilateral to Square.
Set your shapes to reasonable values (you do not have to change how you did this from
before) then print each shape's area, perimeter and the object (with the points) directly
(using << as you did before). For this to work polymorphically, your operator <<
functions will need to be implemented as wrappers around polymorphic (virtual)
methods.
Add two functions to your client (one to take a pointer to and one to take a reference to a
Quadrilateral) and print the perimeter, area and object itself for each shape by calling the
shape's methods or friend functions inside these two functions.
Call the functions with a reference and then a pointer to each object you declare, then
loop through your array passing the pointers (or dereferencing the pointers and passing
the references) to print each shape's area, perimeter and object (with the points). Verify
the values printed using polymorphism are the same as those printed by directly
accessing the shapes.
Download