//	File:  shptest1.cpp
//	Author:  M. Sebern
//	Date:  15-Jun-1995
//	Purpose:
//		Test operation of shape class hierarchy.
//	Revision history:
//
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <iostream.h>
#include <fstream.h>
#include "shape1.h"

int main(void)
{
	ofstream outfile("shptest1.txt");
	assert(outfile);
	Shape::Out(outfile); // Set Shape log output
	static const int num_shapes = 5;
	Shape*	shapes1[num_shapes];

	outfile << "Creating shapes." << endl;
	shapes1[0] = new Circle(Point(1,3),2);
	shapes1[1] = new Line(Point(0,0), Point (3,4.5));
	shapes1[2] = new Rectangle(Point(1,2),Point(5,10));
	shapes1[3] = new FancyLine(Point(2,5),Point(3,6),FancyLine::DASHED);
	outfile << "Test object creation/assignment" << endl;
	FancyLine line1 (Point(99,88), Point(-10,-2), FancyLine::DOTTED);
	FancyLine line2;
	line2 = line1;
	outfile << "Test self-assignment:" << endl;
	line2 = line2;
	shapes1[4] = line1.MakeCopy();

	int ii;
	outfile << "Drawing array 1 shapes." << endl;
	for (ii = 0; ii < num_shapes; ii++)
	{
		shapes1[ii]->Draw();
	}

	Shape*	shapes2[num_shapes];
	outfile << "Copying array 1 shapes to array 2." << endl;
	for (ii = 0; ii < num_shapes; ii++)
	{
		shapes2[num_shapes - ii - 1] = shapes1[ii]->MakeCopy();
	}
	outfile << "Deleting array 1 shapes." << endl;
	for (ii = 0; ii < num_shapes; ii++)
	{
		delete shapes1[ii];
		shapes1[ii] = NULL;
	}
	outfile << "Drawing/deleting array 2 shapes." << endl;
	for (ii = 0; ii < num_shapes; ii++)
	{
		shapes2[ii]->Draw();
		delete shapes2[ii];
		shapes2[ii] = NULL;
	}
	return 0;
}

