Guest User

Untitled

a guest
Dec 9th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. import random
  2. import time
  3. from plane_map import plane_map
  4.  
  5.  
  6. #Project_test
  7.  
  8. def prints_greeting():
  9. #Prints the Introductory Greeting
  10. print("Alaska Airlines acquired Virgin America in 2016.")
  11.  
  12. time.sleep(2)
  13.  
  14. print("\nSince then, Sir Richard Branson has been counting the grains of sand on Necker Island, his private hideaway in the Caribbean.")
  15.  
  16. time.sleep(3)
  17.  
  18. print("\nIt's taken him two years, but he's nearly done counting, and he's ready to launch his next airline.")
  19.  
  20. #ef: url?
  21. time.sleep(3)
  22.  
  23. print("\nYou've been chosen as one of the lucky few to take the inaugural flight.")
  24.  
  25. time.sleep(3)
  26.  
  27. def flyer_ready():
  28. #Returns if they're ready to fly
  29. while True:
  30. travel_choice = input("\nAre you ready for takeoff? [Y/N]").upper()
  31.  
  32. if travel_choice not in ["Y","N"]:
  33. print ("\nThat's not an option. Let's try this again.")
  34. True
  35. elif travel_choice == "N":
  36. print("\nBack to counting sand for Richard. \n\nEnd of Program")
  37. return(travel_choice)
  38. elif travel_choice == "Y":
  39. print("\nGreat!")
  40. return(travel_choice)
  41.  
  42. def seat_col(choose_to_fly,seat_columns):
  43. #Returns seat column (e.g.wind,mid,ais)
  44. while True:
  45. print("\nWould you like a seat in the:\n")
  46.  
  47. for key in seat_columns:
  48. print ("[",key,"]",seat_columns[key])
  49.  
  50. seat_col_choice = input("\nEnter here>").upper()
  51.  
  52. if seat_col_choice not in seat_columns:
  53. print("\nThat's not an option. Let's try this again.")
  54. else:
  55. break
  56. #ef check if there are open seats, if so:
  57. return (seat_col_choice)
  58.  
  59. def seat_row_generator(max_row,offered_rows,seat_type):
  60.  
  61. while True:
  62.  
  63. row = random.randint(1,max_row+1)
  64.  
  65. if row not in offered_rows:
  66. break
  67. elif row in offered_rows and seat_type not in offered_rows[row]:
  68. break
  69.  
  70. return row
  71.  
  72. def seat_row(seat_col,seat_columns,max_row,offered_row):
  73.  
  74. #and check for seats that are already taken
  75.  
  76. print("\nYou're in luck! We have an open",seat_columns[seat_col],f'seat. It\'s in row {offered_row}.\n')
  77.  
  78. time.sleep(2)
  79.  
  80. plane = plane_map(max_row,offered_row,seat_col)
  81.  
  82. for i in plane:
  83. print(i,plane[i])
  84.  
  85. def seat_row_work(row):
  86. while True:
  87. print("\nWould you like to:\n\n[1] Select this seat \n[2] Roll the dice again")
  88. #\n[3] Choose a specific seat from the map
  89.  
  90. works = input("\nEnter here>")
  91.  
  92. if works not in ("1","2","3"):
  93. print("\nThat's not an option. Let's try this again.")
  94. else:
  95. break
  96.  
  97. return works
  98.  
  99. #based on the seat column, select a random seat number and ask if it works for them.
  100. def print_boarding_pass(seat_type,offered_row):
  101. print(f'\nYou\'re ready for takeoff!\n\nPrint your boarding pass:\n\nRow: {offered_row} Seat: {seat_type}\n\n<<Save to Apple wallet>>')
  102.  
  103. ######################################################
  104.  
  105. #variables
  106. seat_columns = {"W":"Window", "M":"Middle", "A":"Aisle"}
  107. max_row = 30
  108. offered_rows = {}
  109.  
  110. def run_seat_picker():
  111. """Runs seat picker"""
  112. prints_greeting()
  113. choose_to_fly = flyer_ready()
  114. while choose_to_fly == "Y":
  115.  
  116. seat_type = seat_col(choose_to_fly, seat_columns)
  117.  
  118. offered_row = seat_row_generator(max_row,offered_rows, seat_type)
  119.  
  120. if offered_row in offered_rows:
  121. offered_rows[offered_row].append(seat_type)
  122. else:
  123. offered_rows[offered_row] = [seat_type]
  124.  
  125. #print (offered_rows)
  126.  
  127. seat_row_num = seat_row(seat_type, seat_columns,max_row,offered_row)
  128.  
  129. row_works = seat_row_work(seat_row_num)
  130.  
  131. if row_works == "2":
  132. #print(offered_rows)
  133. continue
  134. #elif row_works == "3":
  135. #row and seat equals user inputs
  136.  
  137. print_boarding_pass(seat_type,offered_row)
  138. break
  139. # playing = True
  140. # while playing:
  141. # get user's birth information
  142. # generate horoscope
  143. # print horoscope
  144. # ask to continue
  145.  
  146. run_seat_picker()
  147.  
  148. ###########################################
  149. #Basic Rules
  150. #1) Must choose from three types of seats: window, middle, aisle
  151. #2) Every seat has a row # with the three types of seats above.
  152. #3) Can only choose 1 seat
  153. #4) Can not choose a seat that's already taken
  154. #5) When a seat with a row # and letter is chosen, the program ends
  155.  
  156. # Pseudocode the Work Flow
  157. # Offer open seat and check if the user wants it.
  158. # If they want it, print the seat map with the spot taken and wish them a good flight.
  159. # If they don't want it, ask if they want window, middle, or aisle.
  160. #(make sure what's offered isn't what was previously offered)
  161. # If they want it, print the seat map with the spot taken and wish them a good flight.
  162. #If they don't want it, ask what row they want.
  163. #(make sure what's offered isn't what was previously offered)
  164. # Offer open seat and check if the user wants it.
  165. # If they want it, print the seat map with the spot taken and wish them a good flight.
  166.  
  167.  
  168. # What data do we need to keep track of
  169. # 1) What seat type and row #s have already been offered and turned down.
Add Comment
Please, Sign In to add comment