/* ***************************************************************************
   *   (c)Copyright notice - 2003 - Uwe "Ed" Beltz, JD.                      *
   *    All rights reserved.                                                 *
   *                                                                         *
   *    DISCLAIMER: The efforts including the development, research, and     *
   *  testing of the following program, and its effectiveness, are solely    *
   *  my effort in conjunction with training in INLS161 - Spring 2003.       *
   *  The author makes no warranty of any kind, expressed or implied,        *
   *  with regard to this, or any associated program.  The author shall not  *
   *  be held liable in any event for incidental or consequential damages    *
   *  arising in connection with, or arising out of, the use, furnishing,    *
   *  or performance of this program.                                        *
   *************************************************************************** */
import javax.swing.*;
import java.awt.*;
import java.text.DecimalFormat;


public class Seater
{
    //create an array of seats all initialized to false (not assigned)
    boolean seat[] = {false, false, false, false, false, false, false, false, false, false};
    int i;  //counter
    boolean available; //variable to check availability of seat
    String seatNum = ""; //holds the seat number assigned
    
    /* This method assigns a seat in nonsmoking */
    public String assignNon()
    {
	seatNum = "";
	
	for (i=5; i<10; i++)
	{
	    //only assign the seat if it's not already taken
	    if (!seat[i])                            
	    {
		seat[i] = true;
		seatNum = String.valueOf(i+1);
		break;
	    }
	}
	return seatNum;
    }
    
    /* This method assigns a seat in smoking */
    public String assignSmoking()
    {
	seatNum = "";
	
	for (i=0; i<5; i++)
	{
	    //only assign seat if it's not already taken
	    if (!seat[i])
	    {
		seat[i] = true;
		seatNum = String.valueOf(i+1);
		break;
	    }
	}
	return seatNum;
    }
    
    /* This method checks to see if all the seats on the flight have been */
    /* assigned. If there is still an open seat it returns true, other-   */
    /* wise if all seats are taken it returns false.                      */
    public boolean checkAll()
    {
	available = false;
	i=0;
	
	while (i<10 && available == false)
	{
	    if (!seat[i])
	    {
		available = true;                
	    }
	    i++;
	}
	return available;
    }
    
    /* This method checks for seat availability in nonsmoking. Returns    */
    /* true if there's an available seat, false if not.                   */
    public boolean checkNon()
    {
	available = false;
	i=5;
	
	while (i<10 && available == false)
	{
	    if (!seat[i])
	    {
		available = true;
	    }
	    i++;
	}
	return available;
    }
    
    /* This method checks for seat availability in smoking. Returns true  */
    /* if there's an available seat, false if not.                        */
    public boolean checkSmoking()
    {
	available = false;
	i=0;
	
	while (i<5 && available == false)
	{
	    if (!seat[i])
	    {
		available = true;
	    }
	    i++;
	}
	return available;
    }
}
	    
		

