Add main.py
This commit is contained in:
129
main.py
Normal file
129
main.py
Normal file
@@ -0,0 +1,129 @@
|
||||
import random
|
||||
|
||||
def printMenu(Balance, menu):
|
||||
if menu == "main":
|
||||
print("Balance: "+ str(Balance))
|
||||
print("(1: Buy / 2: Sell) Buy/Sell menu: ")
|
||||
print("3. See stock prices: ")
|
||||
print("4. See remaining time: ")
|
||||
print("5. check the index")
|
||||
|
||||
print("6. goto next day: ")
|
||||
elif menu == "prices":
|
||||
print("Kwik trip: " + str(kwiktripStockPrice))
|
||||
print("Apple computers: " + str(appleStockPrice))
|
||||
print("Microsoft: " + str(microsoftStockPrice))
|
||||
print("Walmart Super Store: " + str(walmartStockPrice))
|
||||
print("Car company: " + str(carStockPrice))
|
||||
elif menu == "index":
|
||||
print("The index as of day " + str(day) + " is " + str(indexPrice))
|
||||
elif menu == "daysleft":
|
||||
print("as of today you have " + str(daysleft) + ". have fun!")
|
||||
"""
|
||||
def newday():
|
||||
kwiktripStockPrice = kwiktripStockPrice + random.randint(-100.99, 100.99)
|
||||
appleStockPrice = appleStockPrice + random.randint(-100.99, 100.99)
|
||||
microsoftStockPrice = microsoftStockPriice + random.randint(-100.99, 100.99)
|
||||
walmartStockPrice = walmartStockPrice + random.randint(-100.99, 100.99)
|
||||
carStockPrice = carStockPrice + random.randint(-100.99, 100.99)
|
||||
"""
|
||||
|
||||
balance = 1000
|
||||
kwiktripStockPrice = 100 + random.randint(-100, 100)
|
||||
appleStockPrice = 100 + random.randint(-100, 100)
|
||||
microsoftStockPrice = 100 + random.randint(-100, 100)
|
||||
walmartStockPrice = 100 + random.randint(-100, 100)
|
||||
carStockPrice = 100 + random.randint(-100, 100)
|
||||
|
||||
kwiktrip = 0
|
||||
apple = 0
|
||||
microsoft = 0
|
||||
walmart = 0
|
||||
car = 0
|
||||
day = 1
|
||||
|
||||
|
||||
indexPrice = (kwiktripStockPrice + appleStockPrice + microsoftStockPrice + walmartStockPrice + carStockPrice) / 5
|
||||
|
||||
daysleft = int(input("how many days do you wish to play?"))
|
||||
|
||||
while daysleft > -1:
|
||||
printMenu(balance, "main")
|
||||
|
||||
|
||||
stockcost = [kwiktripStockPrice, appleStockPrice, microsoftStockPrice, walmartStockPrice, carStockPrice]
|
||||
|
||||
|
||||
usrinput = input()
|
||||
if usrinput == "1":
|
||||
print("1. Kwik trip: " + str(kwiktripStockPrice))
|
||||
print("2. Apple computers: " + str(appleStockPrice))
|
||||
print("3. Microsoft: " + str(microsoftStockPrice))
|
||||
print("4. Walmart Super Store: " + str(walmartStockPrice))
|
||||
print("5. Car company: " + str(carStockPrice))
|
||||
stockinput = int(input("what stock do you want to buy?: "))
|
||||
amountinput = int(input("how many stocks?: "))
|
||||
|
||||
amountcost = int(amountinput) * int(stockcost[int(stockinput)-1])
|
||||
rusure = input("are you sure this will cost you " + str(amountcost) + " and you have $" + str(balance) + ": ")
|
||||
if balance < amountcost:
|
||||
print("you can not complete this purchace your poor")
|
||||
else:
|
||||
if rusure == "yes" or rusure == "y" or rusure == "Y" or rusure == "Yes":
|
||||
balance = balance - amountcost
|
||||
if stockinput == 1:
|
||||
kwiktrip = kwiktrip + amountinput
|
||||
elif stockinput == 2:
|
||||
apple = apple + amountinput
|
||||
elif stockinput == 3:
|
||||
microsoft = microsoft + amountinput
|
||||
elif stockinput == 4:
|
||||
walmart = walmart + amountinput
|
||||
elif stockinput == 5:
|
||||
car = car + amountinput
|
||||
print("\033c", end="")
|
||||
|
||||
elif usrinput == "2":
|
||||
print("1. Kwik trip: " + str(kwiktripStockPrice) + "you own: " + str(kwiktrip))
|
||||
print("2. Apple computers: " + str(appleStockPrice) + "you own: " + str(apple))
|
||||
print("3. Microsoft: " + str(microsoftStockPrice) + "you own: " + str(microsoft))
|
||||
print("4. Walmart Super Store: " + str(walmartStockPrice) + "you own: " + str(walmart))
|
||||
print("5. Car company: " + str(carStockPrice) + "you own: " + str(car))
|
||||
stockinput = int(input("what stock do you want to sell?: "))
|
||||
amountinput = int(input("how many stocks?: "))
|
||||
amountpayout = int(amountinput) * int(stockcost[int(stockinput)-1])
|
||||
|
||||
rusure = input("are you sure you will sell " + str(stockinput) + " and make " + str(amountpayout) + ": ")
|
||||
if rusure == "yes" or rusure == "y" or rusure == "Y" or rusure == "Yes":
|
||||
balance = balance + amountpayout
|
||||
if stockinput == 1:
|
||||
kwiktrip = kwiktrip - amountinput
|
||||
elif stockinput == 2:
|
||||
apple = apple - amountinput
|
||||
elif stockinput == 3:
|
||||
microsoft = microsoft - amountinput
|
||||
elif stockinput == 4:
|
||||
walmart = walmart - amountinput
|
||||
elif stockinput == 5:
|
||||
car = car - amountinput
|
||||
print("\033c", end="")
|
||||
elif usrinput == "3":
|
||||
printMenu(balance, "prices")
|
||||
elif usrinput == "4":
|
||||
printMenu(balance, "daysleft")
|
||||
elif usrinput == "5":
|
||||
printMenu(balance, "index")
|
||||
elif usrinput == "6":
|
||||
print("\033c", end="")
|
||||
day = day + 1
|
||||
daysleft = daysleft - 1
|
||||
kwiktripStockPrice = abs(kwiktripStockPrice + random.randint(-100, 100))
|
||||
appleStockPrice = abs(appleStockPrice + random.randint(-100, 100))
|
||||
microsoftStockPrice = abs(microsoftStockPrice + random.randint(-100, 100))
|
||||
walmartStockPrice = abs(walmartStockPrice + random.randint(-100, 100))
|
||||
carStockPrice = abs(carStockPrice + random.randint(-100, 100))
|
||||
|
||||
|
||||
stockcost = [kwiktripStockPrice, appleStockPrice, microsoftStockPrice, walmartStockPrice, carStockPrice]
|
||||
|
||||
indexPrice = (kwiktripStockPrice + appleStockPrice + microsoftStockPrice + walmartStockPrice + carStockPrice) / 5
|
||||
Reference in New Issue
Block a user