import java.util.HashMap;
import java.util.Map;


public class MenuSystem {

	private static Menu currentMenu;
	private Map<String,Menu> menusMap = new HashMap<String,Menu>();
	private Map<String,MenuItem> menuItemsMap = new HashMap<String,MenuItem>();
	
	public MenuSystem() 
	{
		// TODO Auto-generated method stub
		Customer customer;
		for(int i = 0; i < 10; i++) {
			customer = new Customer("Person" + i, i, "male", "pass" + i);
			HandleAuthorization.putPerson("Person" + i, customer);
		}
		
		Person person = new Employee("Boss", 42, "male", "password");
		HandleAuthorization.putPerson("Boss", person);
		
/*		  try {
		        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		        String str = "";
		        while (str != null) {
		        	printMenu();
		            str = in.readLine();
		            //process(str);
		            if(str.equals("")) {
		            	System.out.println("Empty string:");
		            	break;
		            }
		            if(str.equals("\n")) {
		            	System.out.println("New line:");
		            	break;
		            }
		            if(str.equals("0")) {
		            	System.out.println("Quit:");
		            	break;
		            }
		        }
		    } catch (IOException e) {
		    }
*/
		NavigationMenu main = new NavigationMenu(null);
		menusMap.put("main", main);
		
		NavigationMenu mainCustomer = new NavigationMenu(main);
		menusMap.put("mainCustomer", mainCustomer);
		
		NavigationMenu mainEmployee = new NavigationMenu(main);
		menusMap.put("mainEmployee", mainEmployee);
		
		LoginMenu login = new LoginMenu(main);
		menusMap.put("login", login);
		
		LogoutMenu logout = new LogoutMenu(main);
		menusMap.put("logout", logout);
		
		ReserveMenu reserve = new ReserveMenu(mainCustomer);
		menusMap.put("reserve", reserve);
		
		CheckInMenu checkIn = new CheckInMenu(mainEmployee);
		menusMap.put("checkIn", checkIn);

		CheckOutMenu checkOut = new CheckOutMenu(mainEmployee);
		menusMap.put("checkOut", checkOut);

		//Menu items
		MenuItem loginMI, logoutMI, customerMI, employeeMI, reserveMI, checkInMI, checkOutMI;
		loginMI = new MenuItem("Log in", login);
		logoutMI = new MenuItem("Log out", logout);
		customerMI = new MenuItem("Customer menu", mainCustomer);
		employeeMI = new MenuItem("Employee menu", mainEmployee);
		reserveMI = new MenuItem("Reserve room", reserve);
		checkInMI = new MenuItem("Check in", checkIn);
		checkOutMI = new MenuItem("Check out", checkOut);
		
		
		//Define menu structure
		main.addItem(loginMI);
		main.addItem(logoutMI);
		main.addItem(customerMI);
		main.addItem(employeeMI);
		
		mainCustomer.addItem(reserveMI);

		mainEmployee.addItem(checkInMI);
		mainEmployee.addItem(checkOutMI);
		
		//login.addItem(new MenuItem("Return to previous menu", main));
		
		// Create some rooms
		/*for(int i = 100; i < 110; i++) {
			new Room(""+i, 1, false);
		}
		for(int i = 200; i < 210; i++) {
			new Room(""+i, 2, true);
		}
		for(int i = 300; i < 310; i++) {
			new Room(""+i, 4, false);
		}*/
		new Room("The Princess Suite", 4, true, 999.99f);
		new Room("The Royal Suite", 6, true, 1999.99f);
		new Room("The Imperial Suite", 8, true, 2999.99f);
		new Room("The Penthouse Suite", 10, true, 4999.99f);
		new Room("The Presidential Suite", 12, true, 9999.99f);
		
		//while(main.executeMenu() == false){
			//Keep offering menu, until valid choice is made
		//}
		currentMenu = main;
		
	}
	
	public static Menu getCurrentMenu()
	{
		return currentMenu;
	}
	
	public static void setCurrentMenu(Menu currentMenu)
	{
		MenuSystem.currentMenu = currentMenu;
	}

}
