Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revision Both sides next revision
cs-142:airplane-seating-and-checking [2015/06/04 12:19]
cs142ta created
cs-142:airplane-seating-and-checking [2015/06/04 12:25]
cs142ta [Source.cpp]
Line 373: Line 373:
 void display_seating_chart(Passenger * seating_chart[][SEATS_PER_ROW]) void display_seating_chart(Passenger * seating_chart[][SEATS_PER_ROW])
 { {
 +        //First print a row of seat labels (e.g., A, B, C, D)
  cout << " ​   ";  cout << " ​   ";
  for (int seat = 0; seat < SEATS_PER_ROW;​ seat++)  for (int seat = 0; seat < SEATS_PER_ROW;​ seat++)
Line 380: Line 381:
  cout << " ​  ";​  cout << " ​  ";​
  }  }
 +                // NOTE: the NOTE in the lookup_passenger_by_seat function explains ​
 +                //       the relationship between the seat label (e.g., '​A'​) and the seat index (e.g., 0)
  char seat_char = FIRST_SEAT + seat;  char seat_char = FIRST_SEAT + seat;
  cout << seat_char << " ";  cout << seat_char << " ";
  }  }
  cout << endl;  cout << endl;
 +
 +        // Print the 2D seating chart matrix
  for (int row = 0; row < ROWS; row++)  for (int row = 0; row < ROWS; row++)
  {  {
- cout << row << " | ";+ cout << row << " | "; ​// row label and left cabin wall
  for (int seat = 0; seat < SEATS_PER_ROW;​ seat++)  for (int seat = 0; seat < SEATS_PER_ROW;​ seat++)
  {  {
  if (seat == SEATS_PER_ROW / 2)  if (seat == SEATS_PER_ROW / 2)
  {  {
- cout << " ​  ";​+ cout << " ​  "; ​// aisle
  }  }
- if (seating_chart[row][seat] == NULL)+ if (seating_chart[row][seat] == NULL) // if seat is unoccupied
  {  {
- cout << "_ ";+ cout << "_ "; ​// unoccupied
  }  }
  else  else
  {  {
- cout << "X ";+ cout << "X "; ​// occupied
  }  }
  }  }
- cout << "​|"​ << endl;+ cout << "​|"​ << endl; // right cabin wall
  }  }
  
cs-142/airplane-seating-and-checking.txt ยท Last modified: 2015/06/09 13:03 by cs142ta
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0