Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. import os, sys
  2. from secret import flag
  3.  
  4. items = []
  5.    
  6. def menu():
  7.     print "SANTA's Decoration shop yay!"
  8.     print "1. Add new decoration to the shopping list"
  9.     print "2. View your shopping list"
  10.     print "3. Ask Santa for a suggestion"
  11.    
  12.     sys.stdout.write ("Your choice: ")
  13.     sys.stdout.flush ()
  14.     return sys.stdin.readline ()
  15.  
  16. class Decoration(object):
  17.     def __init__(self, type, quantity):
  18.         self.quantity = quantity
  19.         self.type = type
  20.     def print_decoration(self):
  21.         print ('{0.quantity} x ... '+ self.type).format(self)
  22.  
  23. def leak_source_code():
  24.     print "Santa shows you how his shop works to prove that he doesn't scam you!\n\n"
  25.    
  26.     with open(__file__, 'r') as f:
  27.         print f.read()
  28.        
  29. def add_item():
  30.     sys.stdout.write ("What item do you like to buy? ")
  31.     sys.stdout.flush ()
  32.     type = sys.stdin.readline ().strip ()
  33.    
  34.     sys.stdout.write ("How many of those? ")
  35.     sys.stdout.flush ()
  36.     quantity = sys.stdin.readline ().strip () # Too lazy to sanitize this
  37.    
  38.     items.append(Decoration(type, quantity))
  39.    
  40.     print 'Thank you, your items will be added'
  41.    
  42. def show_items():
  43.     for dec in items:
  44.         dec.print_decoration()
  45.  
  46. print ("""           ___
  47.         /`   `'.
  48.        /   _..---;
  49.        |  /__..._/  .--.-.
  50.        |.'  e e | ___\\_|/____
  51.       (_)'--.o.--|    | |    |
  52.      .-( `-' = `-|____| |____|
  53.     /  (         |____   ____|
  54.     |   (        |_   | |  __|
  55.     |    '-.--';/'/__ | | (  `|
  56.     |      '.   \\    )"";--`\\ /
  57.     \\        ;   |--'    `;.-'
  58.     |`-.__ ..-'--'`;..--'`
  59.     """)
  60.  
  61. while True:
  62.     choice = menu().strip ()
  63.    
  64.     if(choice == '1'):
  65.         add_item()
  66.     elif(choice == '2'):
  67.         show_items()
  68.     elif(choice == '3'):
  69.         leak_source_code()
  70.     else:
  71.         print "Invalid choice"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement