Python Forum
Simple Text Shop Simulator Feedback
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Text Shop Simulator Feedback
#1
Hello all, I am very new to coding as in I have only 7 hours of research and experience under my belt. I chose to pick up Python and it's been a blast. I've created a small text shop simulator from scratch and would like to have some feedback on my first project. It currently stops after you purchase something and I don't think I will continue any further unless I can start making the code more complex.

I want to start heading towards GUI coding and getting different displays for my code, but I have no clue where to start learning about how to do so. Any suggestions? Or any suggestions on what to add to this code or what to do next in my coding adventure?

# requirement
correct_country = "Australia"

# contact details
name = input("Please type your full name: ")
current_year = 2019
while True:
    try:
        birth_year = int(input("Please type your birth year: "))
    except ValueError:
        print("That is not a valid birth year!")
        continue
    if birth_year < 1000:
        print ("That is not a valid birth year, please try again in a four digit format!")
        continue
    if birth_year < 1910:
        print ("There is no way you are over 105 years old.")
        continue
    if birth_year > 2003:
        print ("You must be 16 years or older to use our shop.")
        continue
    if birth_year > 1910:
        break
age = current_year - birth_year

while True:
    country = str(input("Please type your country of residence: "))
    if country == correct_country:
        print("Verification Successful.")
        break
    else:
        print("Sorry, our store is currently only available to Australians")
        continue
        
# greeting
greeting = "Welcome to our newest member, "
info = "They are "
info2 = " years old."
full_greeting = greeting + name + ". " + info + str(age) + info2

print("----------------------------------------------------------")
print(full_greeting)
print("----------------------------------------------------------")

# material availability
wood = "Wood"
metal = "Metal"
wood_num = 221
metal_num = 95
full_material_message = "Our warehouse currently holds " + str(wood_num) + " pieces of " + wood + " and " + str(metal_num) + " pieces of " + metal + "."

print(full_material_message)

# cost details
cost_wood = 8.50
cost_metal = 14.20
full_cost_message = wood + " currently costs " + "$" + str(cost_wood) + " per piece and " + metal + " currently costs " + "$" + str(cost_metal) + " per piece."

print(full_cost_message)

# client order
# wood = 0
# metal = 1

print("----------------------------------------------------------")
print("Selection of material, " + wood + " = 0 and " + metal + " = 1.")
print("Available " + wood + " stock = " + str(wood_num) + ".")
print("Available " + metal + " stock = " + str(metal_num) + ".")

while True:
    try: 
        chosen_material = int(input("Please choose a material: "))
    except ValueError:
        print("That is not a valid material type, please try again!")
        continue
    if chosen_material > 1:
        print("That is not a valid material type, please try again!")
        continue
    if chosen_material == 0:
        print("You have selected " + wood + ".")
        break
    if chosen_material == 1:
        print("You have selected " + metal + ".")
        break

while True:
    try:
        amount = int(input("Please type your desired amount: "))
    except ValueError:
        print("That is not a valid number, please try again!")
        continue
    if chosen_material == 0 and amount > 221:
        print("Sorry, we do not have enough of that material in stock! Available " + wood + " stock = " + str(wood_num) + ".")
        continue
    if chosen_material == 1 and amount > 95:
        print("Sorry, we do not have enough of that material in stock! Available " + metal + " stock = " + str(metal_num) + ".")
        continue
    if chosen_material == 0 and amount < 222:
        break
    if chosen_material == 1 and amount < 96:
        break
    
# order 1 process

# wood process
if chosen_material == 0:
    total_cost = amount * cost_wood
    wood_num = wood_num - amount
    sale_message = name + " has bought " + str(amount) + " piece(s) of " + wood + " for " + "$" + str(total_cost)
    
    if amount == 1:
        sale_message = name + " has bought " + str(amount) + " piece of " + wood + " for " + "$" + str(total_cost)
    if amount == 0:
        sale_message = name + " has decided not to purchase any " + wood + "."
    if amount > 1:
        sale_message = name + " has bought " + str(amount) + " pieces of " + wood + " for " + "$" + str(total_cost)
    
    if wood_num == 1:
        stock_message = "There is now " + str(wood_num) + " piece of " + wood + " left in stock." 
    if wood_num == 0:
        stock_message = "Our " + wood + " stock is currently empty."
    if wood_num > 1:
        stock_message = "There are now " + str(wood_num) + " pieces of " + wood + " left in stock."
    
    print("----------------------------------------------------------")
    print(sale_message)
    print(stock_message)    

# metal process
else:
    if chosen_material == 1:
        total_cost = amount * cost_metal
        metal_num = metal_num - amount
        
    if amount == 1:
        sale_message = name + " has bought " + str(amount) + " piece of " + metal + " for " + "$" + str(total_cost)
    if amount == 0:
        sale_message = name + " has decided not to purchase any " + metal + "."
    if amount > 1:
        sale_message = name + " has bought " + str(amount) + " pieces of " + metal + " for " + "$" + str(total_cost)
    
    if metal_num == 1:
        stock_message = "There is now " + str(metal_num) + " piece of " + metal + " left in stock."
    if metal_num == 0:
        stock_message = "Our " + metal + " stock is currently empty."    
    if metal_num > 1:
        stock_message = "There are now " + str(metal_num) + " pieces of " + metal + " left in stock."
        

    print("----------------------------------------------------------")
    print(sale_message)
    print(stock_message)
Reply


Messages In This Thread
Simple Text Shop Simulator Feedback - by Dash - Apr-18-2019, 11:56 AM
RE: Simple Text Shop Simulator Feedback - by Dash - Apr-18-2019, 02:01 PM
RE: Simple Text Shop Simulator Feedback - by Dash - Apr-19-2019, 09:09 AM
RE: Simple Text Shop Simulator Feedback - by Dash - Apr-19-2019, 01:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Shop Revisted menator01 0 2,552 Oct-30-2022, 04:40 PM
Last Post: menator01
  Feedback on simple 'Mock Up' scripts fxJoan 7 5,404 Aug-22-2018, 08:07 AM
Last Post: Mekire
  My first 'GAME' It is a simple text adventure jackspendiff942003 3 4,690 Aug-08-2017, 10:22 PM
Last Post: jackspendiff942003

Forum Jump:

User Panel Messages

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