|
||||||||
ADT - List Exercisenot collectedYou will work with ADTs (Abstract Data Type) and debugging. The
exercise requires you to develop a simple class using a given ADT. Also
you will work with debugging and error corrections. Your first task is to develop an abstract base class named Counter describing the interface of the abstract data type (ADT) Counter for which a UML diagram is shown below. The member function lower() retrieves the lower bound on the Counter, upper() retrieves the upper bound, get() retrieves the current value of the counter, set() sets the current value of the counter, inc() increases by 1 the counter value, dec() decrements by 1 the counter value. These functions are abstract/virtual. Next you will develop a derived class SimpleCounter that implements all of the abstracted member functions. Now create a program testcounter which tries to create an object of the class SimpleCounter implementing the Counter interface. It then runs through a sequence of incrementing and decrementing the counter value.
In other words, you have Counter as abstract class, whose implementation is done by subclasses, as for instance SimpleCounter. Also, you have a separate program (testcounter) that uses the same abstract data type by its implementation class. Note: your class should be derived publicly from Counter. Note: You will want your program to have some method to indicate when a counter has exceeded its valid range. This can range from terminating the program with an error message to printing a warning message and continuing to adding an "invalid" flag to the counter which gets set on error conditions. This implementation is left up to you. |
||||||||
© Lynne Grewe |