views:

206

answers:

2

hi, i need help modelling a use case diagram from a topic, it will be in java GUI

Design a Calculator that

1.Allow user to key in a legitimate arithmetic statement that involves number, operator +, - and bracket '(' and ')' ;

2.When user press “Calculate” button, display result;

3.Some legitimate statement would be ((3+2)-4+2) (equals 3) and (-2+3)-(3-1) (equals -1);

4.You should NOT use a pre-existing function that just take in the statement as a parameter and returns the result but you should write the logic of parsing every character in your code.

5.Store the last statement and answer so it is displayed when user press the “Last calculation” button.

i have designed two use case diagrams using UML on netbeans 6.5.1, one of the use case i am not sure whether is it containing too much use cases etc, while the other is what i think could be too vague for the topic.i hope to get some feedback on whether the use case diagram are appropriate, thanks.i included a what it would be like in GUI

use cast 1

alt text alt text

+1  A: 

In the second use case diagram, you have user having use cases based on the sequence of actions performed to implement the use cases in the first. These would be better represented as either an activity diagram or state machine - the user cares about getting the results of a calculation, and it is incidental that to get these results expressions need to be keyed in buttons need to be pressed. When creating use cases concentrate on the goals that the originator of the use case has, rather than how the system might help them achieve these goals .

On another point, the spec you give says nothing about simulating a keyboard using a Java GUI, or a backspace key as in your mock-up. Check with the stakeholders whether 'allow the user to key in' just means giving them somewhere to type, or providing an on-screen keypad.

Pete Kirkham
thanks for your answer,"When creating use cases concentrate on the goals that the originator of the use case has, rather than how the system might help them achieve these goals ." this has helped me cleared some doubts, i believe the main problem is i am having trouble identifying use case, and on the specs part, this is a homework and a very simple one at it, and is to be created with a java GUI,while the other features;backspace,etc i believe can be added in for "bonus" marks,
kyrogue
+1  A: 

First thing you must know about use case diagrams is that its supposed to describe functionality of a system for which actor. It should be on such a high level that anyone without knowledge of programming can understand it. As a programmer, use cases might look very vague to you but thats fine. Its not supposed to say anything about the system, just what it can do.

Some more specific comments:

  • As i mentioned use cases should describe high level functions. Press Calculate is not a function, Calculate is. Press Last Calculation should be Store Last Calculation, etc

  • Its not clear what Press Backspace does. Backspace is just a key, not a use case.

  • The ParserSys package tries to describe internals of a system. This does not belong in a use case diagram. Other diagrams should be used for this.

  • Use case Store Result (first pic) should not be in this diagram. But if thats something User can do, it should be associated with User.

Edit:

..i believe the main problem is i am having trouble identifying use case..

A good way of identifying use cases is as simple as asking yourself the question: "[Actor] should be able to [what]" (or something similar). [What] is then your use case. If it doesn't fit in this sentence, its probably not a use case.

takoi