first exmaple in chapter10(not using state pattern)