#include <iostream>
using namespace std;
enum class State { InWork, InPub, AtHome };
enum class Event { GoWork, GoPub, GoHome, AnotherBeer };
void signout();
void lockDoor();
void hic();
void minesAPint();
void Transition(Event e);

int main(void)
{
	int x = 0;

	//models transitions:
	cout << "\nEnter a number between 0 and 4:\n";
	cout << "0 = GoWork event \n 1: = GoPub event\n ";
	cout << "2: = GoHome\n 3: = Anotherbeer\n 4:exit program\n";


	while (x != 4)
	{
		cin >> x;
		Transition((Event)x);
	}

}

void Transition(Event e)
//deals with state transitions and actions
{
	static State s = State::AtHome;
	switch (s)
	{
	case State::AtHome:
		switch (e)
		{
		case Event::GoWork:
			s = State::InWork;
			lockDoor();
			break;
		}
		break;
	case State::InWork:
		switch (e)
		{
		case Event::GoPub:
			s = State::InPub;
			signout();
			break;
		case Event::GoHome:
			s = State::AtHome;
			signout();
			break;
		}
		break;
	case State::InPub:
		switch (e)
		{
		case Event::GoHome:
			s = State::AtHome;
			hic();
			break;
		case  Event::AnotherBeer:
			minesAPint();
			break;
		}
		break;

	}
}
void minesAPint()
{
	cout << "Mines a pint!!\n";
}
void signout()
{
	cout << "Good night worker W101\n";
}
void hic()
{
	cout << "I'm off home! Hic!!\n";
}
void lockDoor()
{
	cout << "Click - doors locked - off to work!!\n";
}

