This assignment creates a simple four-function calculator that can be
used to emphasize the strategies of object-oriented programming. A
similar assignment has been used at Brown University for many years.
The interesting feature of this assignment is that it can easily be
coded with no
if statements, using only inheritance
and overriding to implement the dispatch. Each of the digit buttons,
for example, can be a subclass of a more general
class that appends the button value to the display. Each specific instance
has a different value that is set when the button is constructed. Similarly,
the operator buttons can define a method called
that performs the appropriate operation.