A counter variable is normally used in a program to keep track of the current count value.Create your own counter data type which is able to perform common counter operations such as increment (by one) the counter value and decrement (by one) the counter value. It is also able to set the counter to a specific value and to retrieve the counter value. The minimum value the counter can attain is zero, while the maximum value attained is stored in attribute maxValue. The class should have the following private members (attributes): (first picture) In the main program, test the workablity of your member functions by first setting an initial value to the counter. Display this value before proceeding. Then test other functions by randomly incrementing and decrementing the object’s value. Be sure to keep track of your actions. At the same time you should also make sure that your minimum value should not be less than zero. Once this is reached you will not be allowed to do further decrements. Consequently, the maximum value should also be maintained. The user should always ensure that the current value does not exceed the maximum value. If this happens no more increments will be allowed. Display appropriate comments for these two cases. Finally, when there are no more increments or decrements to do, you should print the final value or the set of the operations. For purposes of reusability, separate the driver, specification and implementation files
A counter variable is normally used in a program to keep track of the current count value.Create your own counter data type which is able to perform common counter operations such as increment (by one) the counter value and decrement (by one) the counter value. It is also able to set the counter to a specific value and to retrieve the counter value. The minimum value the counter can attain is zero, while the maximum value attained is stored in attribute maxValue. The class should have the following private members (attributes):
(first picture)
In the main program, test the workablity of your member functions by first setting an initial value to the counter. Display this value before proceeding. Then test other functions by randomly incrementing and decrementing the object’s value. Be sure to keep track of your actions. At the same time you should also make sure that your minimum value should not be less than zero. Once this is reached you will not be allowed to do further decrements. Consequently, the maximum value should also be maintained. The user should always ensure that the current value does not exceed the maximum value. If this happens no more increments will be allowed. Display appropriate comments for these two cases. Finally, when there are no more increments or decrements to do, you should print the final value or the set of the operations. For purposes of reusability, separate the driver, specification and implementation files
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images