473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Seat Assignment Program Problem

Slick47
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.  
Apr 14 '09 #1
3 5630
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
Apr 15 '09 #2
Thank you, I'll give that a try and post any problems I might have :)
Apr 15 '09 #3
JosAH
11,448 Expert 8TB
@Slick47
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
Apr 15 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since...
2
by: Chad | last post by:
I'm in an intro to VB.net class. I'm haveing trouble with this assignment, if anyone could help me please let me know. thanks! Coding Assignment 7-Chapter 8 OOP-CSCI-171 Intro to VB.NET ...
34
by: Chris | last post by:
Is there ever a reason to declare this as if(*this == rhs) as opposed to what I normally see if(this == &rhs) ?
0
by: 1051109210 | last post by:
im suppose to do a "airplane sitting" program 1 a b c d 2 a b c d 3 a b c d (till 7) den if i ask a user to type in their seats... 1 a b x d
3
by: john | last post by:
Hey, I know we use the pointer this to obtain a class object or class member data. I don't follow the reason for example this code. I'am quite confused assingment operator const B...
2
by: thesti | last post by:
hi, i'm asked to create a program in which there's a component like this http://jakkos.110mb.com/images/component.JPG it's like a seat reservation program. in which we are able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.