jeudi 22 décembre 2016

Proper State Pattern

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.

enter image description here


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:

enter image description here

Am I on the right track? Any feedback is good! Thanks in advice.

/P

Aucun commentaire:

Enregistrer un commentaire