Im curious about State Pattern and how to design them correctly. On my previous writen exam I failed on this question:
State Pattern
A PinBallGame can be in three states. In each of the states, a different music loop is played as follows:
- idle: no music is played.
- NormalPlay: music is played by calling the static method MusicOutput::PlayNormal().
- Multiball: music is played by calling the static method MusicOutput::PlayMultiball().
Please complete the following class diagram using the State pattern. Please alfo fill in the method bodies.
On my exam I was thinking of a State Diagram, thereby I failed. Now I want to know how I was supposed to write it.
Here is my answer if I would get the same question today:
Am I on the right track? Any feedback is good! Thanks in advice.
/P
Aucun commentaire:
Enregistrer un commentaire