Please send questions to
st10@humboldt.edu .
#include <iostream>
#include "ColoredPoint3.h"
using namespace std;
//--------------------------------------------------------------------------
// test_ColoredPoint3.cpp
//
// Contract : main : void -> int
// Purpose : do a few quick'n'sleazy tests of the constructors and
// methods of class ColoredPoint3, printing the results
// to the screen.
//
// Examples : not really applicable --- simply prints the results of
// the hard-coded tests to the screen.
//
// by: Sharon M. Tuttle
// last modified: 12-3-03
//
// compile using: (note the inclusion of base class file Point3.o !)
// g++ -o test_ColoredPoint3 test_ColoredPoint3.cpp ColoredPoint3.o Point3.o
//-------------------------------------------------------------------------
int main()
{
// try each constructor
ColoredPoint3 cp1(3, 4, 5, "Purple");
ColoredPoint3 cp2;
// show that the constructors did something, while
// also exercising the accessors
cout << endl;
cout << "TESTING ColoredPoint3 CONSTRUCTORS and ACCESSORS: "
<< endl;
cout << "--------------------------------------------------"
<< endl;
cout << "cp1: " << endl;
cout << " color should be Purple: " << cp1.get_ptColor() << endl;
cout << " x-coord should be 3: " << cp1.get_x() << endl;
cout << " y-coord should be 4: " << cp1.get_y() << endl;
cout << " z-coord should be 5: " << cp1.get_z() << endl;
cout << endl;
cout << "cp2: " << endl;
cout << " color should be Black: " << cp2.get_ptColor() << endl;
cout << " x-coord should be 0: " << cp2.get_x() << endl;
cout << " y-coord should be 0: " << cp2.get_y() << endl;
cout << " z-coord should be 0: " << cp2.get_z() << endl;
// make sure the mutators are operational, too
cout << endl;
cout << "TESTING ColoredPoint3 MUTATORS: "
<< endl;
cout << "--------------------------------------------------"
<< endl;
cp2.set_x(38);
cp2.set_y(2);
cp2.set_z(555);
cp2.set_ptColor("Scarlet");
cout << "cp2 after calling mutators: " << endl;
cout << " color should be Scarlet: " << cp2.get_ptColor() << endl;
cout << " x-coord should be 38: " << cp2.get_x() << endl;
cout << " y-coord should be 2: " << cp2.get_y() << endl;
cout << " z-coord should be 555: " << cp2.get_z() << endl;
cout << endl;
return 0;
}