Ejemplo n.º 1
0
int main()
{
	std::list<MenuItem*> menu;
	std::list<MenuItem*>::iterator it;
	MenuItem menuItem1("Americano", 1500);
	MenuItem menuItem2("Latte", 2000);
	MenuItem menuItem3("Cappuccino", 2000);
	MenuItem menuItem4("Macchiato", 2500);
	MenuItem menuItem5("Espresso", 2500);

	menu.push_back(&menuItem1);
	menu.push_back(&menuItem2);

	Customer customer;
	Barista barista;

	customer.order("Americano", menu, barista);
	Coffee* coffee = customer.getCoffee();

	std::cout << "--- My Coffee ---" << std::endl;
	std::cout << coffee->getName() << std::endl;
	std::cout << coffee->cost() << std::endl;

	return 1;
}
Ejemplo n.º 2
0
StateMachine::State StateMachine::runMainMenu() {
	State nextState;
	ResourceManager &resourceManager = ResourceManager::getInstance();
	sf::RenderWindow &win = resourceManager.win;

	sf::Sprite backGround;
	backGround.SetTexture(resourceManager.textures.getTexture(0,"MenuBackground"));
	backGround.SetPosition(win.GetWidth()/2 - backGround.GetSize().x/2, win.GetHeight()/2 - backGround.GetSize().y/2);
	
	sf::Sprite header;
	header.SetTexture(resourceManager.textures.getTexture(0,"HeaderMagicMemory"));
	header.SetPosition(win.GetWidth()/2 - header.GetSize().x/2, (win.GetHeight()/2 - 300) - header.GetSize().y/2);

	Menu menu;
	Menu::MenuItem menuItem1("New game", gameSetup);
	Menu::MenuItem menuItem2("Reload mice", loading);
	Menu::MenuItem menuItem3("Help", help);
	Menu::MenuItem menuItem4("Credits", credits);
	Menu::MenuItem menuItem5("Quit", quit);
	menu.addMenuItem(menuItem1);
	menu.addMenuItem(menuItem2);
	menu.addMenuItem(menuItem3);
	menu.addMenuItem(menuItem4);
	menu.addMenuItem(menuItem5);
	bool done = false;
	while (!done) {
		resourceManager.mice.update();
		win.Clear();
		sf::Event event;
		while (win.PollEvent(event))
		{
			if (event.Type == sf::Event::Closed) {
				nextState = quit;
				win.Close();
				done = true;
			}
			if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape)) {
				nextState = quit;
				win.Close();
				done = true;
			}
		}
		win.Draw(backGround);
		win.Draw(header);
		resourceManager.processDrawables();
		done = menu.getClickedState(nextState);
		win.Display();
	}
	return nextState;
}