
| Model name | Ball Game behaviour - Design |
|---|---|
| Status | draft |
| Authors | David Hill |
| Documentation | This model describes interactions among the Ball game objects during the game. |
| Object | Type of object | Documentation |
|---|---|---|
|
:Ball | Lifeline object | |
|
:BallGame | Lifeline object | |
|
:Brick | Lifeline object | |
|
:MovingObject | Lifeline object | |
|
:Paddle | Lifeline object | |
|
Outside actor | Outside actor |
| Object name | |
|---|---|
| Class | Ball |
| Stop? | F |
| Documentation |
| In role | In relationship | With object(s) | In role |
|---|---|---|---|
| : Message to | calculateNewDirection: Call | :MovingObject | : Message from |
| : Message to | calculateNewDirection: Call | :Paddle | : Message from |
| : Message to | check position: Call | :MovingObject | : Message from |
| : Return from | : Return | :MovingObject | : Return to |
| : Return from | position: Return | :MovingObject | : Return to |
| : Return from | : Return | :MovingObject | : Return to |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Object name | |
|---|---|
| Class | BallGame |
| Stop? | T |
| Documentation |
| In role | In relationship | With object(s) | In role |
|---|---|---|---|
| : Message from | displayPlayersScore: Call | :BallGame | : Message to |
| : Message from | displayGameOverText: Call | :BallGame | : Message to |
| : Message from | move: Call | :MovingObject | : Message to |
| : Message from | checkHits: Call | :MovingObject | : Message to |
| : Message to | displayPlayersScore: Call | :BallGame | : Message from |
| : Message to | displayGameOverText: Call | :BallGame | : Message from |
| : Message to | decrementBalls: Call | :MovingObject | : Message from |
| : Message to | : Call | Outside actor | : Message from |
| : Return from | : Return | Outside actor | : Return to |
| : Return to | : Return | :MovingObject | : Return from |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Object name | |
|---|---|
| Class | Brick |
| Stop? | F |
| Documentation |
| In role | In relationship | With object(s) | In role |
|---|---|---|---|
| : Message to | increaseScore: Call | :MovingObject | : Message from |
| : Message to | playHitSound: Call | :MovingObject | : Message from |
| : Return from | : Return | :MovingObject | : Return to |
| : Return from | : Return | :MovingObject | : Return to |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Object name | |
|---|---|
| Class | MovingObject |
| Stop? | F |
| Documentation |
| In role | In relationship | With object(s) | In role |
|---|---|---|---|
| : Message from | check position: Call | :Ball | : Message to |
| : Message from | decrementBalls: Call | :BallGame | : Message to |
| : Message from | playHitSound: Call | :Brick | : Message to |
| : Message from | playHitSound: Call | :Paddle | : Message to |
| : Message from | increaseScore: Call | :Brick | : Message to |
| : Message from | calculateNewDirection: Call | :Ball | : Message to |
| : Message to | move: Call | :BallGame | : Message from |
| : Message to | checkHits: Call | :BallGame | : Message from |
| : Return from | : Return | :BallGame | : Return to |
| : Return to | : Return | :Brick | : Return from |
| : Return to | : Return | :Ball | : Return from |
| : Return to | position: Return | :Ball | : Return from |
| : Return to | : Return | :Ball | : Return from |
| : Return to | : Return | :Brick | : Return from |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Object name | |
|---|---|
| Class | Paddle |
| Stop? | F |
| Documentation |
| In role | In relationship | With object(s) | In role |
|---|---|---|---|
| : Message from | calculateNewDirection: Call | :Ball | : Message to |
| : Message to | playHitSound: Call | :MovingObject | : Message from |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| In role | In relationship | With object(s) | In role |
|---|---|---|---|
| : Message from | : Call | :BallGame | : Message to |
| : Return to | : Return | :BallGame | : Return from |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Name | David Hill |
|---|---|
| mailto:info@metacase.com | |
| Contact address | Park Court Upper Essex Street City 5 B8 6QB |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Class name | Ball |
|---|---|
| Attributes | |
| Operations | +display()void, +calculateNewDirection(hitObject:MovingObject)void, +check position()void |
| Package | Game |
| Abstract? | F |
| Active? | F |
| Stereotype | |
| Overridability | |
| Role | |
| Parameters | |
| Constraints | |
| Invariant | |
| Derivation rules | |
| Responsibility | |
| Documentation | Ball is the basic element of the game. Player tries to remove bricks by hitting them with the ball. |
| Simple symbol? | F |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | display |
|---|---|
| Parameters | |
| Return type | |
| Overridability | |
| Stereotype | |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | |
| Postconditions | |
| Body | |
| Documentation | Overriden from superclass to display a round ball rather than a square |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | calculateNewDirection |
|---|---|
| Parameters | in hitObject:MovingObject |
| Return type | |
| Overridability | |
| Stereotype | |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | |
| Postconditions | |
| Body | |
| Documentation |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Parameter | hitObject |
|---|---|
| Data type | MovingObject |
| Direction | in |
| Default value | |
| Effect | |
| Exception? | F |
| Stream? | F |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | check position |
|---|---|
| Parameters | |
| Return type | |
| Overridability | |
| Stereotype | |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | |
| Postconditions | |
| Body | |
| Documentation | Returns the location of the ball. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Package name | Game |
|---|---|
| Stereotype | modelLibrary |
| Documentation | Ball game packace include all the components of the ball game application. Because the application is small not other packages are used for categorization. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Class name | BallGame |
|---|---|
| Attributes | |
| Operations | |
| Package | |
| Abstract? | T |
| Active? | F |
| Stereotype | |
| Overridability | |
| Role | |
| Parameters | |
| Constraints | |
| Invariant | |
| Derivation rules | |
| Responsibility | |
| Documentation | |
| Simple symbol? | T |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Class name | Brick |
|---|---|
| Attributes | +value:int =1 |
| Operations | +playHitSound()void, +increaseScore()void |
| Package | Game |
| Abstract? | F |
| Active? | F |
| Stereotype | |
| Overridability | |
| Role | |
| Parameters | |
| Constraints | |
| Invariant | |
| Derivation rules | |
| Responsibility | |
| Documentation | Single element of the wall. These will disappear, when the ball hits them. |
| Simple symbol? | F |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Name | value |
|---|---|
| Data type | int |
| Default value | 1 |
| Multiplicity | |
| Ordered? | F |
| Unique? | T |
| Sequence? | F |
| Stereotype | |
| Visibility | public |
| Scope | instance |
| Access | |
| Derived? | F |
| Constraints | |
| Documentation | Value of the brick. When ball hits the brick, value will be added to player's currentScore. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | playHitSound |
|---|---|
| Parameters | |
| Return type | |
| Overridability | |
| Stereotype | |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | |
| Postconditions | |
| Body | |
| Documentation | When the ball hits a brick or a paddle, it makes a sound. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | increaseScore |
|---|---|
| Parameters | |
| Return type | |
| Overridability | |
| Stereotype | |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | |
| Postconditions | |
| Body | |
| Documentation | When then ball hits a brick it will disappear and the value of the brick will be added to player's currentScores. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Class name | MovingObject |
|---|---|
| Attributes | +position:Point =100.0@100.0, -velocity:Point =0.0@2.0, +extent:Point, -colour:ColorValue |
| Operations | +display()void, +move(position:Point, direction:int)void, +checkHits()void |
| Package | Game |
| Abstract? | T |
| Active? | F |
| Stereotype | |
| Overridability | |
| Role | model |
| Parameters | |
| Constraints | |
| Invariant | |
| Derivation rules | |
| Responsibility | |
| Documentation | MovingObject is an abstract class for all moving components of the ball game. |
| Simple symbol? | F |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Name | position |
|---|---|
| Data type | Point |
| Default value | 100.0@100.0 |
| Multiplicity | |
| Ordered? | F |
| Unique? | T |
| Sequence? | F |
| Stereotype | |
| Visibility | public |
| Scope | class |
| Access | |
| Derived? | F |
| Constraints | |
| Documentation | Position stores the current location of the top left corner of the moving object in the game. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Name | velocity |
|---|---|
| Data type | Point |
| Default value | 0.0@2.0 |
| Multiplicity | |
| Ordered? | F |
| Unique? | T |
| Sequence? | F |
| Stereotype | |
| Visibility | private |
| Scope | instance |
| Access | |
| Derived? | F |
| Constraints | |
| Documentation | Stores the direction and speed of the movement. Positive x values are to the right, positive y values up |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Name | extent |
|---|---|
| Data type | Point |
| Default value | |
| Multiplicity | |
| Ordered? | F |
| Unique? | T |
| Sequence? | F |
| Stereotype | |
| Visibility | public |
| Scope | instance |
| Access | |
| Derived? | F |
| Constraints | |
| Documentation | Moving objects have width and height |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Name | colour |
|---|---|
| Data type | ColorValue |
| Default value | |
| Multiplicity | |
| Ordered? | F |
| Unique? | T |
| Sequence? | F |
| Stereotype | |
| Visibility | private |
| Scope | instance |
| Access | |
| Derived? | F |
| Constraints | |
| Documentation | Colour of the moving object. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | display |
|---|---|
| Parameters | |
| Return type | |
| Overridability | |
| Stereotype | |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | |
| Postconditions | |
| Body | |
| Documentation | Displays the object at its current position. The default is to fill its extent with its colour; subclasses can override for more interesting shapes and effects. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | move |
|---|---|
| Parameters | in position:Point, in direction:int |
| Return type | |
| Overridability | |
| Stereotype | action |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | Is not outside the game field, ie. player has not missed the ball. |
| Postconditions | |
| Body | |
| Documentation | Move changes the location and direction of the moving object in the game field according to the given position and direction. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Parameter | position |
|---|---|
| Data type | Point |
| Direction | in |
| Default value | |
| Effect | |
| Exception? | F |
| Stream? | F |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Parameter | direction |
|---|---|
| Data type | int |
| Direction | in |
| Default value | |
| Effect | |
| Exception? | F |
| Stream? | F |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Operation name | checkHits |
|---|---|
| Parameters | |
| Return type | |
| Overridability | |
| Stereotype | |
| Visibility | public |
| Operation type | instance |
| Query? | F |
| Preconditions | |
| Postconditions | |
| Body | |
| Documentation | Check whether moving object has hit some other object. |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Class name | Paddle |
|---|---|
| Attributes | +maxSpeed |
| Operations | +playHitSound()void |
| Package | Game |
| Abstract? | F |
| Active? | F |
| Stereotype | |
| Overridability | |
| Role | |
| Parameters | |
| Constraints | |
| Invariant | |
| Derivation rules | |
| Responsibility | |
| Documentation | Player tries to keep the ball in play by hitting it with the paddle. |
| Simple symbol? | F |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |
| Name | maxSpeed |
|---|---|
| Data type | |
| Default value | |
| Multiplicity | |
| Ordered? | F |
| Unique? | T |
| Sequence? | F |
| Stereotype | |
| Visibility | public |
| Scope | instance |
| Access | |
| Derived? | F |
| Constraints | |
| Documentation | Maximum speed of the paddle can change during the game |
| Subgraph type | Graph's name |
|---|---|
| Decomposition | none |
| Explosions | none |