Python - Menu Program

Only available on StudyMode
  • Topic: Course, Vegetarianism, Selection
  • Pages : 14 (1437 words )
  • Download(s) : 42
  • Published : May 6, 2013
Open Document
Text Preview
#Marius Mazuolis
#14-12-2012
#assignment Menu Program

#-------------------------------------
#open file and read data assining it to 2 dimension list
def openFile(fileName):
bufferFile = open(fileName)
bufferTxt = bufferFile.read()
bufferFile.close()
bufferLines = bufferTxt.split("\n")
bufferTable = []
ln=0
for line in bufferLines:
if len(line) > 0:
if ln != 0:
dataLine = line.split(",")
dataLine[0] = dataLine[0].capitalize()
bufferTable = bufferTable + [dataLine]
else:
dataLine = line.split(",")
for dt in dataLine:
i = dataLine.index(dt)
dataLine[i] = dt.upper()
bufferTable = bufferTable + [dataLine]
ln+=1
return bufferTable
#-------------------------------------

#-------------------------------------
#function to check if number less than 10 to add 0 in front
#(send 9 receive 09)
def lessThan10(number):
if number < 10:
number = "0" + str(number)
else:
number = str(number)
return number
#-------------------------------------

#-------------------------------------
#format price
def formatPrice(pricesss):
if float(pricesss) < 10:
pricesss = "£ {:.2f}".format(float(pricesss))
else:
pricesss = "£ {:.2f}".format(float(pricesss))
return pricesss
#-------------------------------------

#-------------------------------------
#print all Data in nice formated table
def printallTable():
print(' '.ljust(25),'Full menu list of the dishes'.upper()) print('')
ln = 0
for line in allTable:
if ln!= 0:
dishNo = lessThan10(ln) + " - "
print(dishNo.ljust(5), line[0].ljust(12), line[1].ljust(30) ,formatPrice(line[2]).ljust(8),line[3].ljust(8)) else:
print("No - ",line[0].ljust(12), line[1].ljust(30) ,line[2].ljust(8),line[3].ljust(8)) print("")
ln += 1
print('')
#-------------------------------------

#-------------------------------------
#main menu for selection main action
def mainMenu():
print('*********************************')
print('* 1 - Order meal *')
print('* 2 - Add dish to the list *')
print('* 3 - Remove dish from the list *')
print('* 4 - Dish price change *')
print('* 5 - Order history *')
print('* 6 - Order list for kitchen *')
print('* 7 - Save list and exit *')
print('*********************************')
#-------------------------------------

#-------------------------------------
#adding lines to clear Shell screen
def clearShell(lnCount):
if lnCount == 0:
lnCount = 100
while lnCount!=0:
print('')
lnCount -= 1
#-------------------------------------

#-------------------------------------
#get single formated dish from the table
def singleDish(num,simb):
line = []
dishLine = ''
if simb == 'formated':
print(lessThan10(num).ljust(5), allTable[num][0].ljust(12), allTable[num][1].ljust(30) ,formatPrice(allTable[num][2]).ljust(8),allTable[num][3].ljust(8)) else:
for data in allTable[num]:
if allTable[num].index(data) != 0:
dishLine += simb + data
else:
dishLine += data
return dishLine
#-------------------------------------

#-------------------------------------
# print single tipe courses
def singleCourse(courseType):
ln = 0
for line in allTable:
if line[0] == courseType:
singleDish(ln, 'formated')
ln += 1

#-------------------------------------

#-------------------------------------
#to count how many courses are in the table len of course type def lenCT(courseType):
x0 = 0
for line in...
tracking img