Connecting Tech Pros Worldwide Help | Site Map

Seat Assignment Program Problem

Slick47's Avatar
Newbie
 
Join Date: Feb 2009
Location: Waukesha / Whitewater
Posts: 6
#1: Apr 14 '09
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:

Expand|Select|Wrap|Line Numbers
  1. SeatAssign.java:54: setSeats(char[][]) in SeatAssign cannot be applied to (char[][],int,int)
  2.             setSeats (Seats, row, col);
  3.             ^
  4.  
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.


Expand|Select|Wrap|Line Numbers
  1. import javax.swing.*;
  2. import java.text.*;
  3. import java.util.*;
  4.  
  5.  
  6.  
  7. class SeatAssign{
  8.  
  9.  
  10. final static int ROWS = 14;
  11. final static int COLS = 7;
  12.  
  13. //MAIN MAIN MAIN MAIN
  14. public static void main (String[] args){
  15.  
  16.  
  17.     char[][] Seats;
  18.     char seat;
  19.     int opt;
  20.     Seats = new char[ROWS][COLS];
  21.     Scanner scanner;
  22.     scanner = new Scanner(System.in);
  23.  
  24.     setSeats(Seats);
  25.  
  26.     System.out.println("Welcome to Seat Selector Pro! The realistic seat selection program!");
  27.  
  28. do{
  29.  
  30.     System.out.println();
  31.     System.out.println("Please select an option:\n 0:Exit \n 1:Display Seats \n 2:Book a seat");//choose opt area
  32.     opt = scanner.nextInt();
  33.  
  34.     if (opt == 0)
  35.         return;
  36.     else if (opt == 1)
  37.         DisplaySeats(Seats);                                   //call up the DisplaySeats function
  38.  
  39.  
  40.  
  41.     else if (opt == 2){
  42.  
  43.     int row, col;
  44.     char seatseat;
  45.  
  46.     System.out.print("Please enter a row number <1-13>:");
  47.         row = scanner.nextInt();
  48.         System.out.print("Please enter a column number <1-6>:");
  49.         col = scanner.nextInt();
  50.  
  51.     *************seatseat = getSeat (Seats, row, col);*************
  52.  
  53.         if (seatseat == 'o'){
  54.             setSeats (Seats, row, col);
  55.             DisplaySeats (Seats);
  56.         }
  57.         else
  58.         System.out.println("Seat is occupied.");
  59.  
  60.                                                //call up the setSeats function
  61.         setSeats(Seats);
  62.     }
  63.  
  64.  
  65.     else
  66.         System.out.println("Error in number selection, only enter 0, 1, or 2.");
  67.     } while(opt != 0);
  68.  
  69.  
  70.  
  71. /*
  72.     Seats[4][3] = 'x';
  73.     seat = getSeat(Seats, 4, 3);
  74.     if (seat == 'x') //occupied
  75.         System.out.println("seat[4][3] is occupied " + seat);
  76. */
  77.  
  78. }
  79.  
  80.  
  81. //MAIN MAIN MAIN MAIN
  82.  
  83.  
  84. //setSeats setSeats setSeats setSeats
  85. public static void setSeats (char Seats[][]){
  86.  
  87.     int row, col;
  88.  
  89.     for (row = 1; row < ROWS; row++)
  90.     for (col = 1; col < COLS; col++)
  91.                 Seats[row][col] = 'o';
  92.         }
  93.  
  94.  
  95. //setSeats setSeats setSeats setSeats
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. //DISPLAY SEATS DISPLAY SEATS DISPLAY SEATS
  103.         public static void DisplaySeats(char Seats[][]){
  104.  
  105.             int row, col, colnum;
  106.  
  107.  
  108.         //Numbers for the columns
  109.             System.out.print("   ");
  110.             for (colnum = 1; colnum < 7; colnum++){
  111.                 System.out.format(" %1d" , colnum);
  112.  
  113.                 }
  114.             System.out.println();
  115.         //Numbers for the columns
  116.  
  117.             for (row = 1; row < ROWS; row++){
  118.                 System.out.format("%2d", row);
  119.  
  120.             for (col = 0; col < COLS; col++)
  121.                 System.out.print(Seats[row][col] + " ");
  122.                 System.out.println();
  123.             }//for row
  124.  
  125. }
  126.  
  127.  
  128. //DISPLAY SEATS DISPLAY SEATS DISPLAY SEATS
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. //getSeats getSeats getSeats getSeats getSeats
  137.  
  138. public static char getSeat(char Seats[][], int r, int c){
  139.  
  140.  
  141.  
  142.  
  143.  
  144.             return Seats[r][c];
  145.         //maybe a scanner funciton in here?
  146.  
  147.  
  148.         }
  149. //getSeats getSeats getSeats getSeats getSeats
  150.  
  151.  
  152.  
  153. }//END
  154.  
  155.  
mschenkelberg's Avatar
Member
 
Join Date: Jun 2007
Posts: 44
#2: Apr 15 '09

re: Seat Assignment Program Problem


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
Slick47's Avatar
Newbie
 
Join Date: Feb 2009
Location: Waukesha / Whitewater
Posts: 6
#3: Apr 15 '09

re: Seat Assignment Program Problem


Thank you, I'll give that a try and post any problems I might have :)
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#4: Apr 15 '09

re: Seat Assignment Program Problem


Quote:

Originally Posted by Slick47 View Post

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:

Expand|Select|Wrap|Line Numbers
  1. setSeats(char[][]) in SeatAssign cannot be applied to (char[][],int,int) 
  2.  
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
Reply