An example of the state pattern using doors in c++