Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if else statements
#1
class Store:
    Day = 1
    Money = 5
    StoreName = "Lemonade Stand"
    StoreCount = 1
    StoreCost = 3
    StoreProfit = 1.5
    StoreList = []

    def __init__(self, StoreName, StoreCount, StoreCost, StoreProfit):
        self.StoreName = StoreName
        self.StoreCount = StoreCount
        self.StoreCost = StoreCost
        self.StoreProfit = StoreProfit

    @staticmethod
    def DisplayGameInfo(self):
        print("-----------------------------------")
        print("Day #" + str(self.Day))
        print("Money = ${:0,.2f}".format(self.Money))

    @staticmethod
    def DisplayStoreInfo(self):

        print("Store Name : %s, StoreCount = #%d " % (self.StoreName, self.StoreCount))
        print("-----------------------------------")

    def BuyStore(self):
        if self.StoreCost <= Store.Money:
            self.StoreCount += 1
            Store.Money -= self.StoreCost
        else:
            print("You don't have enough money")

    def NextDay(self):
        self.Day += 1
        DailyProfit = self.StoreProfit * self.StoreCount
        Store.Money += DailyProfit


Store.StoreList.append(Store)

while True:
    Store.DisplayGameInfo(Store)
    Store.DisplayStoreInfo(Store)

    print("Available Options (N)ext Day, (B)uy Store, (E)xit")
    Choice = input('Please select an option')

    if Choice is 'B' or 'b':
        Store.StoreList[0].BuyStore(Store)

    elif Choice is 'N' or 'n':
        Store.StoreList[0].NextDay(Store)

    elif Choice is 'E' or 'e':
        break
    else:
        print("Bad Input")

print("Thanks for playing Idle Tycoon")
This shows there is no error, but when in run it and choose the first if statement, it only executes that statement and if i choose to execute the second if statement, it will just keep ignoring my command and continue to run the first if statement.
#NB the ide that i'm using is intellij and i'm also just a beginner
So anyone can help me? will appreciate it a lot. 've been stuck here for days and almost want to give up
Reply


Messages In This Thread
if else statements - by remy - Sep-14-2018, 10:05 AM
RE: if else statements - by Mekire - Sep-14-2018, 10:12 AM
RE: if else statements - by remy - Sep-15-2018, 03:48 AM
RE: if else statements - by volcano63 - Sep-15-2018, 02:51 PM
RE: if else statements - by ichabod801 - Sep-15-2018, 08:09 PM
RE: if else statements - by volcano63 - Sep-15-2018, 08:42 PM
RE: if else statements - by gruntfutuk - Sep-16-2018, 01:17 PM
RE: if else statements - by LinkAiris - Apr-24-2024, 10:22 PM
RE: if else statements - by DeaD_EyE - Apr-25-2024, 07:27 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020