CS 4448 - Spring 1998
Object-Oriented Programming and Design
Homework #5

Due on Thursday, February 19 at the start of class.

Bring 2 copies of your homework.

Design a Calculator

This calculator will be designed in 3 parts. Show your designs in the same way as in Homework #4 using Class Diagrams. Also show a Module Diagram and then create 2 representative examples of uses of the calculator and show the Interaction Diagram. In assignment #4 a large number of you had a closed minded design. You looked at the specification I gave you and did not make your own interpretation of what was need for the big picture. So, in this assignment you need to have the interface I am specifying below but keep an open mind and anticipate future needs that one might have on your design. It should be noted that no design is ever final, we always go back at some later date and make modifications. MS Word seemed complete but then we decide it needs to generate HTML. So if the designers did a good job it only takes a minor redesign to generate HTML. But then it is decided that MS Word needs to be not only a word processor but also a web browser. This time it is a larger redesign but again it is done with hopes of anticipating future design needs. Enough said, go to it.

Why fixed names?

The class names and method names are fixed since someone else wants your classes to use with their classes. They have created their own stubs, okay maybe not on this example, and will be replacing them with your code.

The Screen

This class needs to be named Screen. The screen has one instance variable name value. The screen has the methods - +, -, *, /, ln, factorial, store:, and value. The store: method is used to modify value.

The Memory

This class needs to be named Memory. The memory has one instance variable named value. The memory needs to support the following methods - +, -, store:, and value.

The Calculator

This class is named Calculator. It contains two instance variables named aScreen and aMemory. Make sure the calculator starts in a nice, do this with a method called initialize. This calculator will do +, -, *, /, ln, factorial, and store:. The method exceeds: will be used on the calculator to see if the screen value is greater then aNumber. clearScreen and screen can be used on the calculator to do what you think they do. The calculator will also support addMemory, clearMemory, subMemory, and readMemory methods. addMemory and subMemory perform operations on the memory using the screen (aCalculator addMemory takes the screen and adds it to the memory). The other two should be easy to figure out.
Adam Jonathan Griff, computer@griffmonster.com
Copyright © University of Colorado. All rights reserved.
Revised: February 17, 1998