Comm4nd0

Virtual Till

Jul 7th, 2015
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.71 KB | None | 0 0
  1. import menu
  2. import datetime
  3.  
  4. # Print a welcome message
  5. # Print the menu
  6. # Allow user to enter items from the menu
  7. # Add them up and print a receipt.
  8.  
  9. def welcome():
  10.     print"Welcome to your till, start by entering the items 1 at a time\n"
  11.  
  12. A = menu.Menu("A", "Chicken Strips","3.50",3.5)
  13. B = menu.Menu("B", "French Fries","2.50",2.5)
  14. C = menu.Menu("C", "Hamburger","4.00",4)
  15. D = menu.Menu("D", "Hotdog","3.50",3.5)
  16. E = menu.Menu("E", "Large Drink","1.75",1.75)
  17. F = menu.Menu("F", "Medium Drink","1.50",1.5)
  18. G = menu.Menu("G", "Milk Shake","2.25",2.25)
  19. H = menu.Menu("H", "Salad","3.75",3.75)
  20. I = menu.Menu("I", "Small Drink","1.25",1.25)
  21.  
  22. print A.price
  23.  
  24. def enter_items():
  25.     price = 0.0
  26.     input = True
  27.     today = datetime.date.today()
  28.     receipt = open("D:\Python\Till\Receipt.txt", "w")
  29.     receipt.write("MENU RECEIPT\n\n")
  30.     print(today)
  31.  
  32.     while input == True:
  33.         item = raw_input("\nEnter item letter: ")
  34.         if item.upper() == "A":
  35.             print A.name
  36.             receipt.write(A.name)
  37.             receipt.write(" | ")
  38.             receipt.write(A.text_price)
  39.             receipt.write("\n")
  40.             price = price + A.price
  41.             print("Sub-Total = %.2f" % price)
  42.  
  43.         elif item.upper() == "B":
  44.             print B.name
  45.             receipt.write(B.name)
  46.             receipt.write("   | ")
  47.             receipt.write(B.text_price)
  48.             receipt.write("\n")
  49.             price += B.price
  50.             print("Sub-Total = %.2f" % price)
  51.  
  52.         elif item.upper() == "C":
  53.             print A.name
  54.             receipt.write(C.name)
  55.             receipt.write("      | ")
  56.             receipt.write(C.text_price)
  57.             receipt.write("\n")
  58.             price += C.price
  59.             print("Sub-Total = %.2f" % price)
  60.  
  61.         elif item.upper() == "D":
  62.             print A.name
  63.             receipt.write(D.name)
  64.             receipt.write("         | ")
  65.             receipt.write(D.text_price)
  66.             receipt.write("\n")
  67.             price = price + D.price
  68.             print("Sub-Total = %.2f" % price)
  69.  
  70.         elif item.upper() == "E":
  71.             print A.name
  72.             receipt.write(E.name)
  73.             receipt.write("    | ")
  74.             receipt.write(E.text_price)
  75.             receipt.write("\n")
  76.             price = price + E.price
  77.             print("Sub-Total = %.2f" % price)
  78.  
  79.         elif item.upper() == "F":
  80.             print A.name
  81.             receipt.write(F.name)
  82.             receipt.write("   | ")
  83.             receipt.write(F.text_price)
  84.             receipt.write("\n")
  85.             price = price + F.price
  86.             print("Sub-Total = %.2f" % price)
  87.  
  88.         elif item.upper() == "G":
  89.             print G.name
  90.             receipt.write(G.name)
  91.             receipt.write("     | ")
  92.             receipt.write(G.text_price)
  93.             receipt.write("\n")
  94.             price = price + G.price
  95.             print("Sub-Total = %.2f" % price)
  96.  
  97.         elif item.upper() == "H":
  98.             print H.name
  99.             receipt.write(H.name)
  100.             receipt.write("          | ")
  101.             receipt.write(A.text_price)
  102.             receipt.write("\n")
  103.             price = price + H.price
  104.             print("Sub-Total = %.2f" % price)
  105.  
  106.         elif item.upper() == "I":
  107.             print I.name
  108.             receipt.write(I.name)
  109.             receipt.write("    | ")
  110.             receipt.write(I.text_price)
  111.             receipt.write("\n")
  112.             price = price + I.price
  113.             print("Sub-Total = %.2f" % price)
  114.  
  115.         elif item.upper() == "P":
  116.             receipt.write("\n\n         TOTAL | %.2f" % price)
  117.             receipt.close()
  118.             input = False
  119.         else:
  120.             print"You have entered an incorrect item.\nPlease try again."
  121.  
  122. def show_receipt():
  123.     with open("D:\Python\Till\Receipt.txt", "r") as receipt:
  124.         data=receipt.read()
  125.         print("\n\n"+data)
  126.     receipt.close()
  127.  
  128. welcome()
  129. enter_items()
  130. show_receipt()
  131.  
  132. #######################################################################################################################################
  133.  
  134. class Menu():
  135.     def __init__(self, key, name, text_price, price):
  136.         self.key = key
  137.         self.name = name
  138.         self.text_price = text_price
  139.         self.price = price
  140.  
  141.         print "[",key,"]", name, price
  142.  
  143.  
  144.     def print_menu(self):
  145.         print"[A] Chicken Strips - $3.50"
  146.         print"[B] French Fries - $2.50"
  147.         print"[C] Hamburger - $4.00"
  148.         print"[D] Hotdog - $3.50"
  149.         print"[E] Large Drink - $1.75"
  150.         print"[F] Medium Drink - $1.50"
  151.         print"[G] Milk Shake - $2.25"
  152.         print"[H] Salad - $3.75"
  153.         print"[I] Small Drink - $1.25"
  154.         print"[P] to print receipt"
Advertisement
Add Comment
Please, Sign In to add comment