In a game called FictionalGame the players can be either be individuals or teams; team members are
Fantastic news! We've Found the answer you've been seeking!
Question:
In a game calledFictionalGamethe players can be either be individuals or teams; team members are in turn players, that can be either individuals or teams, and so on, in an unusual (for games) recursive structure. In the UML class diagram below (left) you see how this is modelled with the Composite pattern.
- In an example instance of FictionalGame you have the team Eagles composed by the members Joe (individual), Ann (individual) and Skylarks (team). The team Skylarks is composed by Mary (individual) and Robins (team). The team Robins is composed by Mark (individual). This is depicted in the UML object diagram below (right). State whether we could possibly have, in some object diagram, an object of the class Player, justifying your answer. (10 marks)
- Suppose you have an operation print(String) with which you can print a string; to print the attribute name of Individual, for example, you call print(name) (pseudo-code). Write in pseudo-code the specification of the operation printname() of Team, which prints the names of all members of the team. (10 marks)
Related Book For
Posted Date: