/* THIS IS THE TEST FILE Grant Chen Due: 10/02/08 CS213 Student ID 908306235 Compiler: Dev-C++ Exercise 4 problem 2 Problem #2: Prob.#2, Ch6, Page 260 Define and test a class for a type called CounterType. An object of this type is used to count things, so it records a count that is a nonnegative whole number. Include a default constructor that sets the counter to zero and a constructor with one argument that sets the counter to the value specified by its argument. Include member functions to increase the count by one and to decrease the count by one. Be sure that no member function allows the value of the counter to become negative. Also include a member function that returns the current count value and one that outputs the count to a stream. This last function should have one formal parameter of type ostream. Embed your class definition in a test program. Header *.h implementation *.cpp #Include "DayofYear.cpp"? test // main() *.cpp zip and submit */ #include #include "countertype.h" //#include "countertype_implementation" using namespace std; int main() { CounterType countDefault, countObject; // Intializing two CounterTypes. int x, countValue, addValue, minusValue; cout << "Now testing CounterType." << endl; cout << "The default constructor value is: "; x = countDefault.returnCounter(); // Calling default constructor. cout << x << endl; // Outputting value of the default constructor. cout << "Now enter an integer: "; cin >> countValue; // Taking in an int. countObject = CounterType(countValue); // Initializing countObject to int cout << "The value of the new one is: "; x = countObject.returnCounter(); // cout << x << endl; // Displaying value of countObject through x. cout << "Now pick an integer to add: "; cin >> addValue; // Taking in an integer to add cout << endl << "The new value is: "; countObject.counterPlus(addValue); // Adding integer. x = countObject.returnCounter(); cout << x << endl; // Displaying value after adding. cout << "Now pick an integer to subtract: "; cin >> minusValue; // Taking an integer to subtract. cout << endl << "The new value is: "; countObject.counterMinus(minusValue); // Subtracting integer. x = countObject.returnCounter(); cout << x << endl; // Displaying value after subtracting. // Test ostream here return 0; }