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?
Question 3
Draw a UML diagram that uses composition to model the following C++ class:
Draw a UML diagram that uses attributes to model the following C++ class:
Question 4
Draw a UML diagram of the part of your web site that is concerned with this
class. Include the following ideas: Your_Home_Page, Your_CS320_Page,
Lab_Page, Source_Code_Page, WWW Pages in general.
(The above is non-standard!)
Question 5
Draw a UML diagram of a Node where: A Node is either Empty, an Atom, or a
Pair. Each Pair has two pointers to nodes called the car and cdr. (This is
the structure of LISP!)
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 ]
Specifications using the Object Constraint Language
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.
C++ Code for MiniCalc
Have look at
[ minicalc.cpp ]
that is the C++ code for 6 of the above classes plus a simple set of
tests. Down load and test it.
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>>