CS 1440 Lab 9

Cover sheetPrevious Activity                                                      Post-Lab

You've been asked by your employer to implement a class to mimic an electronic counter that can count from 0 to 9999 (place the class definition in counter.h and the class implementation in counter.C). The class should contain:

  1. A default constructor (public)
  2. A member function to reset the counter (public)
  3. Member functions to add either 1,10,100, or 1000 to the counter (public)
  4. A member function to display the current count (public)
  5. A member function to check if overflow (more than a count of 9999) has occurred and reset the counter (private?)

Once your class has been implemented. Your employer wants you to provide an easy way to test the counter class. As such, you should create a test program called tester.C. The tester.C program should provide the user with a menu of choices. Based on the user's choice the particular counter member function should be called for testing purposes (you must use a switch statement to do this). This program should continue to loop asking the user for a new choice until the user selects the exit option from the menu. Below is an example of what the menu might look like:

Welcome to the counter class test program!

1. Reset counter
2. Add 1 to counter
3. Add 10 to counter
4. Add 100 to counter
5. Add 1000 to counter
6. Display counter
7. Exit tester

Please select an option (1-7):