-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lemonade.py
More file actions
77 lines (66 loc) · 2.34 KB
/
Copy pathtest_lemonade.py
File metadata and controls
77 lines (66 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# import only system from os
from os import system, name
# import sleep to show output for some time period
from time import sleep
# define our clear function
def clear():
# for windows
if name == 'nt':
_ = system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
def main ():
clear()
titlePage()
sleep(2)
titlePrompts()
def isVerbose():
return True #Debug On
#return False #Debug Off
def titlePage():
welcomeLine = "Hi! Welcome to Lemonsville, California!"
intro = "In this small town, you are in charge of running your own lemonade stand.\nYou can compete with as many other people as you wish, but how much profit \nyou make is up to you (the other stands' sales will not affect your business \nin any way). \n\nIf you make the most money, you're the winner!!"
print(welcomeLine + "\n\n")
print(intro + "\n\n")
def titlePrompts():
newGameQuestion = "Are you starting a new game? (Y or N)\nType your answer and hit Enter/Return ==> "
playerCountQ = "How many people will be playing ==> "
isNewGame = yesNoPrompt(newGameQuestion)
playerCount = howMany(playerCountQ)
def yesNoPrompt(qText):
# Sets to simplify if/else in determining correct answers.
yesChoice = ['yes', 'y']
noChoice = ['no', 'n']
while True:
yesNoPrompt = input(qText)
# Check if our answer is in one of two sets.
if yesNoPrompt.lower() in yesChoice:
# call method
if isVerbose(): print("you typed: " + yesNoPrompt)
return yesNoPrompt
break
elif yesNoPrompt.lower() in noChoice:
# call method
if isVerbose(): print("you typed: " + yesNoPrompt)
return yesNoPrompt
break
else:
if isVerbose(): print("you typed: " + yesNoPrompt)
print("\a")
print("Invalid response, try again.\n")
continue
def howMany(cText):
while True:
count = int(input(cText))
print(count)
if count in range(1,30):
if isVerbose(): print("you typed: " + str(count))
return count
break
else:
if isVerbose(): print("you typed: " + str(count))
print("\a")
print("Invalid response, try again.\n")
continue
main()