add the basic framework of state pattern.