/* THIS IS THE HEADER 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 */ #ifndef COUNTERTYPE_H // Eliminating redefinition errors #define COUNTERTYPE_H class CounterType { public: CounterType(int countValue); // constructor, 1 argument. // PRECONDITION: CounterType contains no assigned count. // POSTCONDITION: CounterType's count contains user-defined int. CounterType( ); // default constructor initialize to zero // PRECONDITION: CounterType contains no assigned count. // POSTCONDITION: CounterType's count contains 0. int counterPlus(int addValue); // function to add. // PRECONDITION: CounterType contains a value. // POSTCONDITION: CounterType's value is incremented by addValue. int counterMinus(int minusValue); // function to subtract // PRECONDITION: CounterType contains a value. // POSTCONDITION: CounterType's value is decreased by minusValue. int returnCounter(); // function to return the value of this. // PRECONDITION: CounterType contains a value. // POSTCONDITION: CounterType's value is returned. void outputCount(ostream &outputValue);// Not yet implemented private: int count; // value of the CounterType. }; #endif