HeadFirstDesignPatterns_python/chapter10_state at main · dancergraham/HeadFirstDesignPatterns_python

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Latest commit

History

History

chapter10_state

Folders and files

NameName

Last commit message

Last commit date

parent directory

..

Chapter 10: State design pattern

State Pattern: allows an object to alter its behaviour when its internal state changes.

The class structure is the same as the Strategy Design Pattern but the intent is different : In the State pattern the subclasses represent specific application states and may cover multiple attributes and methods whereas Strategy allows an algorithm to be selected upon arbitrary criteria and would typically just apply to a single method.

Running the code

python gumballstate.py