I am supposed to pass up my lab work a few weeks back..but i dont seem to get it rite.Pls help me see what is wrong with my code.....this is the question

Write a class PlaneSeat that has the following features. Each PlaneSeat object should hold a seat identification number (seatId), a marker (assigned) that indicates whether the seat is assigned and the customer number (customerId) of the seat holder. The class diagram is given below:

[CENTER]PlaneSeat[/CENTER]
-seatId: int
-assigned: boolean
-customerId: int
+ PlaneSeat(seat_id: int)
+ getSeatID(): int
+ getCustomerID(): int
+ isOccupied(): boolean
+ assign(seat_id: int, cust_id: int): void
+ unAssign(): void

where
    PlaneSeat() - is the constructor for the class.
    getSeatID() – a get method that returns the seat number.
    getCustomerID() – a get method that returns the customer number.
    isOccupied() – a method that returns a boolean on whether the seat is occupied.
    assign() – a method that assigns a seat to a customer.
    unAssigned() – a method that unassigns a seat.

Write a class Plane that comprises 12 seats. The class should create an array of 12 objects from the class PlaneSeat.

The class diagram is given below:

[CENTER]Plane[/CENTER]
-seat: PlaneSeat[ ]
-numEmptySeat: int
+ Plane()
+ sortSeats(): void
+ showNumEmptySeats(): void
+ showEmptySeats(): void
+ showAssignedSeats(): void+ assignSeat(): void
+ unAssignSeat(): void

where
seat – instance variable containing information on the seats in the plane. It is declared as an array of 12 seat objects.
numEmptySeat – instance variable containing information on the number of empty seats.
Plane () – a constructor for the class Plane.
sortSeats () – a method to sort the seats according to ascending order.
showNumEmptySeats() – a method displays the number of empty seats.
showEmptySeats() – a method displays the list of empty seats.
showAssignedSeat() – a method displays the assigned seats.
assignSeat() – a method that assigns a seat.
unAssignSeat() – a method that unassigns a seat.
Implement the class Plane.

Write an application class PlaneApp that implements the seating reservation program. 

The class PlaneApp should be able to support the following:
(1) Show the number of empty seats 
(2) Show the list of empty seats 
(3) Show the list of customers together with their seat numbers in the order of the seat numbers
(4) Assign a customer to a seat
(5) Remove a seat assignment

Here is the code i wrote:

plane.java

import java .util.Scanner;
public class Plane
{
     PlaneSeat[] seat= new PlaneSeat[12];


    private int numEmptySeat;
    Scanner sc = new Scanner (System.in);
    int SeatID,i;
    public Plane()
    {
        for (int i=0;i<12;i++)
        {
           seat[i] = new PlaneSeat(i+1);
        }
        numEmptySeat = 12;
    }

    public void showNumEmptySeat()
    {
        System.out.println ("The number of empty seat is " +numEmptySeat+ ".");
    }
    public void showEmptySeat()
    {
        for (int i=0;i<12;i++)
        {
           if (seat[i].isOccupied()==false);
           System.out.println ("Seat " +seat[i].getSeatID() +"is empty");
        }
    }
    public void showAssignedSeats()
    {
       for (int i=0;i<12;i++)
       {
          if (seat[i].isOccupied()==true)
          System.out.println ("Seat " +seat[i].getSeatID()+ "is assigned to customer " + seat[i].getCustomerID());
       }        
    }
    public void assignSeat()
    {
        System.out.print("Enter seat to be assigned:");
        int seatNumber =sc.nextInt();
        if (seatNumber <=12 && seatNumber >0)
        {
            System.out.print("Enter customer ID :");
            int customerID = sc.nextInt();
            int SeatID ;



                   if (seat[i].isOccupied() == false)
                   {
                       seat[i].assign(seatNumber,customerID);
                       numEmptySeat -=1;
                       System.out.println ("Seat " +seat[i].getSeatID()+ "is assigned to customer " + seat[i].getCustomerID());
                   }
                   else
                   {
                       System.err.println ("Seat " + seat[i].getSeatID() + " is already assigned");
                   }    
            }
        else
        {
            System.out.println ("Invalid seat number");
        }
    }
    public void unAssignSeat()
    {
        System.out.print ("Enter SeatID to be unassigned: ");
        int SeatID = sc.nextInt();
        if (SeatID <= 12 && SeatID >0)
        {
            for (int i=0;i<12;i++)
            {
                if (seat[i].getSeatID() == SeatID)
                {
                    if (seat[i].isOccupied() == true)
                    {
                        seat[i].unAssigned();
                        numEmptySeat += 1;
                        System.out.println ("Seat " + seat[i].getSeatID()+ " is unassigned");
                    }
                    else
                    {
                        System.out.println ("Seat " + seat[i].getSeatID() + " is not assigned yet");
                    }
                }
            }
        }
        else
        {
            System.out.println ("Invalid seat number");
        }
    }




}

planeApp.java

import java.util.Scanner;
public class PlaneApp
{
    public static void main (String []args)
    {

        int i=0,count=0,temp,count1,id,id1;
        Scanner sc = new Scanner(System.in);


        int choice;
        do 
        {
          System.out.println ("1.  Show the number of empty seats");
          System.out.println ("2.  Show the list of empty seat");
          System.out.println ("3.  Show the list of customer alomg with their seat number in the order of the seat numbers");
          System.out.println ("4.  Assign a customer to a seat");
          System.out.println ("5.  Remove a seat assignment");
          System.out.println ("6.  Quit");
          System.out.println ("Enter your choice (1,2,3,4,5 or 6):");
          choice = sc.nextInt();

          switch(choice)
          {
            case 1 :
                    System.out.println ("The number of empty seat is" +count);
                    showNumEmptySeat(); 
                    break;
            case 2 :
                    System.out.println (" The list of empty seat:");
                    showEmptySeat();
                    break;
             case 3 :
                    System.out.println ("n CustomerID tt SeatID");
                    System.out.println ("t============tt==========");
                    showNumEmptySeat();
                    System.out.println ("t" +plane[i].getCustomerID()+("ttt") +Plane[i].getSeatID());
                    break;
             case 4 :
                    System.out.println ("Enter the seat number:");
                    id = sc.nextInt();
                    showAssignedSeat();
                    break;
             case 5 :
                    System.out.println ("Enter the seat number to be removed:");
                    id1 = sc.nextInt();
                    showAssignedSeat();
                    break;
             case 6 :
                    System.out.println("Program terminating...");
                    break;       
                    }

                }while (choice<6);

    }
    }
    public static void showNumEmptySeat()
    {
        if (customerID !=0)
             return 1;
        else
             return 0;
    }
    public static void showEmptySeats()
    {
       int i ;
       for (i=0;i<12;i++)
       {
        temp = plane .numEmptySeats();
        if (temp==0)
        {
            count1 = plane.getEmptySeatNo();
        }
       }

    }

[B][U]planeseat.java[/U][/B]
import java.util.Scanner;
public class PlaneSeat
{
   int seatId;
   boolean assign,unAssigned;
   int customerId;  
   int i;
    public PlaneSeat(int i)
    {
    seatId = i;
    }
   public int getSeatID()      
   {
    return seatId;
   }
   public int getCustomerID()  
   { 
    return customerId;
   }
   public boolean isOccupied() 
   { 
    return assign;
   }
   public int PlaneSeat(int seat_id)
   {
    return seatId = seat_id;
   } 
   public void assign (int seat_id,int cust_id)
   {
    seatId = seat_id;
    customerId = cust_id;
    assign = true;
   }
   public void unAssigned ()
   {

    unAssigned = false;
   }
}

And what's your question?
I'm not going to proofread and debug all your code to figure out what's wrong with it and then supply a corrected version, but we're willing to point you in the right direction if you ask pointed questions.

And what's your question?
I'm not going to proofread and debug all your code to figure out what's wrong with it and then supply a corrected version, but we're willing to point you in the right direction if you ask pointed questions.

Oh...ok...I will be back with my questions.I am so sorry.. I didnt think of that...

Hi. Youre code helped with mine. For yours, you need to initiate class plane in planeApp.java. But since its been six years i think you might have figured tht out..:D

@sonraso123, the post is 6 years old...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.