import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;


public class CheckInMenu extends BasicMenu implements Menu 
{
	private List<Reservation> reservations;
	private String info = "Please select which reservation to check in."; 
	
	public CheckInMenu(Menu parent)
	{
		super(parent);
	}
	
	public boolean executeMenu(){
        reservations = Reservation.getReservations();
        int choice;
        String username;
        String password;
        
		/*try {
	        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	        String str = "";
        
	        while (str != null) {
*/
        String output = "";
        	        

        output += "0) Go to previous menu\n";
        
        for(int i = 0; i < reservations.size(); i++) {
        	output += (i+1) + ") " + reservations.get(i).getRoom().getId() + " reserved by: " + reservations.get(i).getCustomer().getName() + "\n";
        }
	        
	        
	        
	        GUI.setOutputTextArea(output);
	        GUI.setInfoMessage(info);
	        
		        /*
		        
		        System.out.println("");
		        str = in.readLine();*/

		        
		        //ReserveRoomHandler.makeReservation(rooms.get(choice - 1), HandleAuthorization.getCurrentUser());
		        
		        /*
		         * Create a bill, and start charging for the room 
		         */
		        
		        //parent.executeMenu();


	/* catch (NoRoomException e) {
	    	//No rooms available
	    	parent.executeMenu();
	    	return true;
		}*/
		return false;
	}
	
	public boolean processInput(String input)
	{
		try {
			int choice = Integer.parseInt(input);

			if(choice == 0) {
				MenuSystem.setCurrentMenu(parent);
				parent.executeMenu();
				return true;
			}
	        //System.out.println("ReserveRoomHandler.makeReservation(rooms.get(choice - 1), Main.getCurrentUser());");
			CheckInHandler.doCheckIn(reservations.get(choice-1));
			
	        
	    } catch (IndexOutOfBoundsException e) {
	    	System.out.println("Please enter an integer in the range: [0-" + (reservations.size()-1) + "].");
	    } catch (NumberFormatException e) {
	    	System.out.println("Please enter an integer value.");
	    }
	    return true;
	}
}
