Use or not use state template?

I am developing a pinball game for the Uni project, in which there must be 2 modes: an operating mode and a building mode, as a result of which it is possible to design / redesign the layout of the machine.

My initial thought was a state model - however, I am worried that a common interface between states may wrap them in implementation methods that are inconsistent with this state.

Eg. In builder mode, it would be worthwhile to set the position of the bumper or something else; but in the operating mode it will be implemented as doing nothing or throwing an exception - it just seems unpleasant, especially if there are a lot of such methods.

Is there a better design for this?

+5
source share
2

. , , . , , , , .

2 , . , , - , , , . , , , , State.

+11

.

, , , . :

  • - , .
  • , .
  • ( , ..), , , .
  • , , . , , , , , "".

, , , .

, . , , . " ", . , . , , . , , - . . , , /. , , .

P.S. ; -)

+1

All Articles