Seat Assignment Program Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Slick47
    New Member
    • Feb 2009
    • 6

    Seat Assignment Program Problem

    Hey guys, I've gone one problem (so far) in my program to be able to assign and display seats. When I compile my program I get the error:

    Code:
    SeatAssign.java:54: setSeats(char[][]) in SeatAssign cannot be applied to (char[][],int,int)
    			setSeats (Seats, row, col);
    			^
    I have marked this line with some asterisks and was hoping we could deliberate on what the problem with it is? Thanks guys in advance.


    Code:
    import javax.swing.*;
    import java.text.*;
    import java.util.*;
    
    
    
    class SeatAssign{
    
    
    final static int ROWS = 14;
    final static int COLS = 7;
    
    //MAIN MAIN MAIN MAIN
    public static void main (String[] args){
    
    
    	char[][] Seats;
    	char seat;
    	int opt;
    	Seats = new char[ROWS][COLS];
    	Scanner scanner;
    	scanner = new Scanner(System.in);
    
    	setSeats(Seats);
    
    	System.out.println("Welcome to Seat Selector Pro! The realistic seat selection program!");
    
    do{
    
    	System.out.println();
    	System.out.println("Please select an option:\n 0:Exit \n 1:Display Seats \n 2:Book a seat");//choose opt area
    	opt = scanner.nextInt();
    
    	if (opt == 0)
    		return;
    	else if (opt == 1)
    		DisplaySeats(Seats);                                   //call up the DisplaySeats function
    
    
    
    	else if (opt == 2){
    
    	int row, col;
    	char seatseat;
    
    	System.out.print("Please enter a row number <1-13>:");
    		row = scanner.nextInt();
    		System.out.print("Please enter a column number <1-6>:");
    		col = scanner.nextInt();
    
    	*************seatseat = getSeat (Seats, row, col);*************
    
    		if (seatseat == 'o'){
    			setSeats (Seats, row, col);
    			DisplaySeats (Seats);
    		}
    		else
    		System.out.println("Seat is occupied.");
    
    		                                       //call up the setSeats function
    		setSeats(Seats);
    	}
    
    
    	else
    		System.out.println("Error in number selection, only enter 0, 1, or 2.");
    	} while(opt != 0);
    
    
    
    /*
    	Seats[4][3] = 'x';
    	seat = getSeat(Seats, 4, 3);
    	if (seat == 'x') //occupied
    		System.out.println("seat[4][3] is occupied " + seat);
    */
    
    }
    
    
    //MAIN MAIN MAIN MAIN
    
    
    //setSeats setSeats setSeats setSeats
    public static void setSeats (char Seats[][]){
    
    	int row, col;
    
    	for (row = 1; row < ROWS; row++)
    	for (col = 1; col < COLS; col++)
    				Seats[row][col] = 'o';
    		}
    
    
    //setSeats setSeats setSeats setSeats
    
    
    
    
    
    
    //DISPLAY SEATS DISPLAY SEATS DISPLAY SEATS
    		public static void DisplaySeats(char Seats[][]){
    
    			int row, col, colnum;
    
    
            //Numbers for the columns
    			System.out.print("   ");
    			for (colnum = 1; colnum < 7; colnum++){
    				System.out.format(" %1d" , colnum);
    
    				}
    			System.out.println();
            //Numbers for the columns
    
    			for (row = 1; row < ROWS; row++){
    				System.out.format("%2d", row);
    
    			for (col = 0; col < COLS; col++)
    				System.out.print(Seats[row][col] + " ");
    				System.out.println();
    			}//for row
    
    }
    
    
    //DISPLAY SEATS DISPLAY SEATS DISPLAY SEATS
    
    
    
    
    
    
    
    //getSeats getSeats getSeats getSeats getSeats
    
    public static char getSeat(char Seats[][], int r, int c){
    
    
    
    
    
    			return Seats[r][c];
    		//maybe a scanner funciton in here?
    
    
    		}
    //getSeats getSeats getSeats getSeats getSeats
    
    
    
    }//END
  • mschenkelberg
    New Member
    • Jun 2007
    • 44

    #2
    You defined "public static void setSeats (char Seats[][]);" that initialized all the Seats, I think you need to create a new function called setSeat maybe that takes in a row and column and sets only that one row/column Seat value.

    Max

    Comment

    • Slick47
      New Member
      • Feb 2009
      • 6

      #3
      Thank you, I'll give that a try and post any problems I might have :)

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by Slick47
        Thank you, I'll give that a try and post any problems I might have :)
        You should've read the error message, it tells it all:

        Code:
        setSeats(char[][]) in SeatAssign cannot be applied to (char[][],int,int)
        Your compiler is trying to tell you that it found a method setSeats(char[][]) but you are trying to call it with an incompatible parameter list (char[][], int, int). That should've rang a bell. Always first read the compiler's error and/or warning messages and try to understand what it's trying to tell you.

        kind regards,

        Jos

        Comment

        Working...