#created by Jaron Graveley #April 26th, 2011 #This program completes reservations for Jon Von Poechman’s airline in an easy to use program #variable list: #i=counter used to limit the number of seats present on the diagram #n= counter to display the row number on the diagram #num_booked=counts the number of booked seats so the program stops #m=counter used to seperate the rows in the plane #r=row counter #p=position counter #plane=list of seats on the plane showing taken and empty seats #plane_name=same list as plane except it shows names for management use only #seat=shows the letter o for an open seat #name=the users name #row_num= the row number that the passenger wants to sit in #position= the position that the passenger wants to sit in #request= the users requested seat #taken= the equation used to bok the seat #exit= restarts the loop for the next person to book #number= the employee number of the management member i=0 n=1 num_booked=0 m=0 r=1 p=0 plane= plane_name= while r<21: if m==4: r+=1 m=0 p+=1 if p==5: p=1 m+=1 seat="r"+str(r)+"p"+str(p) if seat=="r21p1": break else: seat='o' plane_name.append(seat) plane.append(seat) def diagram(): i=0 n=1 print "Below is a list of available seats marked with a 'o'. Those marked with an 'x' are taken:" print " A B C D" while i<80: print plane[i:i+4], n i+=4 n+=1 while num_booked<80: print "Welcome to Jaron's Airline" name=raw_input("What is your name. If you are a member of airport management please type 'management'. ") if name!='management': diagram() def row(): row_num=input("Which row number would you like to sit in? <1-20> ") if 0>row_num>20: print "That row is not on the plane" row() row() def pos(): position=raw_input("Which seat position would you like to sit in? <A-D> ") position=position.upper() if position=='A': position='1' elif position=='B': position='2' elif position=='C': position='3' elif position=='D': position='4' else: print "That position is not on the plane" pos() pos() request=(row_num*4-(4-int(position)))-1 if plane[request]=='x': print "Sorry that seat is taken, please choose another seat." else: taken=(row_num*4-(4-int(position)))-1 plane[taken]='x' plane_name[taken]=name print "Your seat has successfully been booked." exit=raw_input("press enter to exit") num_booked+=1 elif name=='management': number=raw_input("Please enter your employee number: ") if number=='123': print "Below is a list of passengers that will be boarding the plane:" i=0 n=1 print " A B C D" while i<80: print plane_name[i:i+4], n i+=4 n+=1 exit=raw_input("press enter to exit") else: print "That is not a valid employee number"
this is the results I get when running the program:
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
Type "help", "copyright", "credits" or "license" for more information.
>>> [evaluate funAssign4-plane.py]
Welcome to Jaron's Airline
What is your name. If you are a member of airport management please type 'management'. j
Below is a list of available seats marked with a 'o'. Those marked with an 'x' are taken:
A B C D
Which row number would you like to sit in? <1-20> 5
Which seat position would you like to sit in? <A-D> b
Traceback (most recent call last):
File "<string>", line 81, in <fragment>
NameError: name 'row_num' is not defined
I'm not sure what i am doing wrong i looked at line 81 and all it says is
" if plane[request]=='x':"
Please help me out I'm really confused and just want this program to work.