add cpp version gumball state pattern