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


public class CheckOutMenu extends BasicMenu implements Menu 
{
	List<Payment> payments;
	String info = "Please select whom to check out:";
	
	public CheckOutMenu(Menu parent)
	{
		super(parent);
	}
	
	public boolean executeMenu(){
        payments = Payment.getPayments();
        int choice;
        String username;
        String password;
        
        String output = "";
        

        output += "0) Go to previous menu\n";
        
        for(int i = 0; i < payments.size(); i++) {
        	output += (i+1) + ") " + payments.get(i).getCustomer().getName() + " checked into room: " + payments.get(i).getRoom().getId() + "\n";
        }
		
        GUI.setOutputTextArea(output);
        GUI.setInfoMessage(info);
        
		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());");
	        Payment payment = payments.get(choice-1);
	        CheckOutHandler.doCheckOut(payment);
	        //reservations.get(choice-1).consume();
	        
	        //ReserveRoomHandler.makeReservation(rooms.get(choice - 1), HandleAuthorization.getCurrentUser());
	        
	        /*
	         * Create a bill, and start charging for the room 
	         */
	        
	        //parent.executeMenu();
	        return true;

		} catch (IndexOutOfBoundsException e) {
	    	GUI.setErrorMessage("Please enter an integer in the range: [0-" + (payments.size()-1) + "].");
	    } catch (NumberFormatException e) {
	    	GUI.setErrorMessage("Please enter an integer value.");
	    }/* catch (NoRoomException e) {
	    	//No rooms available
	    	parent.executeMenu();
	    	return true;
		}*/
	    return false;
	}
}
