22.4 THE DESIGN

22.4.1 Design of classes

In the analysis, we have identified seven objects. Now we can group the objects:

Group 1: Board, House, Snake, Ladder, Pebbles

Group 2: Dice

Group 3: Player

A careful analysis will reveal that though snakes and ladders are objects they do not move or change state. Hence, the class board should include snakes, ladders, houses, and pebbles as its integral part and not separate objects.

It leaves us at only three basic objects namely board, dice, and player. Figure 22.2 shows the class diagrams.

 

images

 

Figure 22.2 Class diagrams

22.4.2 Interaction

Now we have to study the interaction between the classes. In ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.