Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Patrick Abbott
- //D-Block
- public static void main(String[] args)
- {
- seatingChart = new int[][] {
- { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
- { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
- { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
- { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
- { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
- { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
- { 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 },
- { 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 },
- { 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 },
- };
- char response = 'Y';
- while ((response == 'Y') || (response == 'y'))
- {
- System.out.print("Pick by Seat <s>, Price <p> ");
- char choice = in.next().charAt(0);
- switch (choice)
- {
- case'S':case's':
- { sellSeatByNumber(seatingChart);
- break; }
- case'P':case'p':
- { sellSeatByPrice(seatingChart);
- break; }
- }
- }
- System.out.print("Would you like to reserve another seat yes or no ");
- response = in.next().charAt(0);
- }
- System.out.print("Thank you come again.");
- }
- public static void printSeats(int seatingChart[][])
- {
- for(int i=0; i<seatingChart.length; i++)
- {
- for(int j=0; j<seatingChart[i].length; j++)
- {
- if (j>0)
- System.out.print("\t");
- System.out.print(seatingChart[i][j]);
- }
- System.out.println();
- }
- }
- public static void sellSeatByPrice(int seatingChart[][])
- {
- System.out.print("Please enter a price for the seat you would like ");
- int price = in.nextInt();
- boolean found = false;
- for (int i=0;i<9;i++)
- for (int j=0;j<10;j++)
- if ((found == true)&&(seatingChart[i][j]==price))
- { seatingChart[i][j]=0; break; }
- printSeats(seatingChart);
- }
- public static void sellSeatByNumber(int seatingChart[][])
- {
- System.out.println("Enter a row then enter a seat number");
- System.out.print("What row would you like to sit on?:");
- int row = in.nextInt();
- row = Math.abs(row-9);
- System.out.print("What seat of that row would you like to sit in");
- int col = in.nextInt();
- col -= 1;
- if (seatingChart[row][col]!=0)
- {
- seatingChart[row][col] = 0;
- printSeats(seatingChart);
- System.out.println("Your seat has been reserved and reflected with a 0 on the chart now");
- }
- else { System.out.println("Sorry that seat is already taken"); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement