Exercise for Lecture 7: I. Write a use-case realization of this use of a calculator: 1. I press "42"; I see " 42" on the display. 2. I press "+"; I see " " on the display. 3. I press "3"; I see " 3" on the display. 4. I press "="; I see " 45" on the display. 5. I press "/"; I see " " on the display. 6. I press "2"; I see " 2" on the display 7. I press "="; I see "22.5" on the display. NOTE: The "user interface" has buttons for 0,1,..,9, +, -, *, /, = and also a display panel that shows an int. The internal hardware can have one or more registers that each holds an int. It can also have an internal "ALU" that does arithmetic. USE THESE entities as needed in your use-case realization. II. For these four objects, draw a communication diagram of Steps 1-4 for the use-case realization: Display (a Form with a label and buttons) DataReg (a register) Accumulator (a register) ALU (does arithmetic) III. Draw a class diagram that would generate the documented behavior. (For now, don't insert delegates or interfaces.) ====================== Sample solution: use an input register, an accumulator register, and ALU 1. I press "42"; I see " 42" on the display: input reg gets 42, display shows 42 2. I press "+"; I see " " on the display. accum gets 42, input reg gets 0, display clears 3. I press "3"; I see " 3" on the display. input reg gets 3, display shows 3 4. I press "="; I see " 45" on the display. ALU adds input reg to accum, places result in input reg display shows 45 (input reg contents) 5. I press "/"; I see " " on the display. like Step 2 6. I press "2"; I see " 2" on the display like Step 3 7. I press "="; I see "22.5" on the display. like Step 4