Add multiplicities and some role names to your diagram. Suggested role names: does, doneBy, ...?
What do you add to it to show that a Container can have any number of Components inside it?
Draw a UML diagram that uses attributes to model the following C++ class:
This is a simple example of the Composite pattern. The composite pattern is in the handout. Use it in your project!
Hint:
Answer: [ 06/ole7.gif ]
Constant::evaluate()
result self.value
Operation::evaluate()
result operator.apply( constant.evaluate(), expression.evaluate())
Addition::apply( i:Int, j:Int)
result i+j
Subtraction::apply( i:Int, j:Int)
result i-jWrite, in the same format as the above, the missing specifications for methods.
Add and test classes for Multiplication and Division.
If you have a lot of spare time, add a lexer and a parser.
. . . . . . . . . ( end of section Question 6 Minicalc) <<Contents | End>>