added the state pattern #16

The state pattern added.