View Single Post
Old May 10th, 2006, 1:22 PM   #1
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 4 NightShade01 is on a distinguished road
Multi array question

Just wanted to know if anyone will look over my code for me. The program is suppose to display a seating chart for an airplane:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D
It should then prompt the user for their seat choice and then replace their choice of seat with an "X" signaling that the seat is taken. Choice of "Q" exits the program. Having a problem displaying the seating chart though. Any suggestions?

import java.util.*:  //import the scanner class

public class Seating{

	boolean taken = false;  //seat intial value is untaken

public String SeatWarn(){
	return "Seat Taken, please choose another seat."  //warn if your seat is taken
}

public void seatTaken(int x, int y){  //change the value of a seat to taken when necessary
	taken = true;
	seats[x][y] = "X";
}

public static void main(String [] args){  //create and display the seating chart
	int counter = 0;
	int[] seats = new int[5][7];
	int row, column;
	for(row = 0; row < seats.length; row++){
		for(column = 0; column < seats[row].length; column++){
			System.out.println(seats[row][column]);
		}
	}
while (count < 36){  //while there are chairs left

Scanner kb = new Scanner(System.in);
System.out.prinln("Please choose a row to sit in:");  //prompt for a row
int rowChoice = kb.nextInt();

System.out.println("Please choose a seat to sit in: (""q"" to exit");  //prompt for a seat
char seatChoice = kb.nextChar();
if (seats[rowChoice][seatChoice].taken = true){  //update the seating chart to reflect seat choosen
	SeatWarn();
}else{
seats[rowChoice][seatChoice].seatTaken(x,y);
}  //Loop

}
NightShade01 is offline   Reply With Quote