
Today we did
Homework:
1 for our food_choices dictionary, add the remaining two foods into our dictionary
2. In our application loop, you need to replace the passes with the code that
3. We have a new function shopping results
class GroceryItem:
def __init__(self,name,price,type):
self.name = name
self.price = price
self.type = type# remember to give me a thumbs up when you have created a project
# Create a directeory called SRC
# create a file named main
# Trader Joe's application
# The options were the different foods you could buy
# you could keep track of what you bought, and the price.
# after the application loop ends (check out) we print all the food and the price
# Basics
# open up a class
# __init__ we are going to put a basic menu, and everything that we need store inbetween loops
# application loop
from groceryitem import GroceryItem
class GroceryStore1:
def __init__(self):
# I want you to create a menu with the following options
# three food items
# an exit option
self.menu ="""
Welcome to Trader Joes what would you like to order
1. Bread - $10
2. Pizza - $8
3. ChocoStrawberries - $12
Enter your Selection(type exit to stop):
"""
# The goal of the application is to keep track of what you buy, and how much it is
# think of the things we would need to store inbetween loops and put here
self.total_cost=0
self.shopping_cart=[]
self.food_choices={}
self.food_choices["1"]= GroceryItem("bread",10,"carb")
def application_loop(self):
# Step1 , while loop (infinite loop)
while True:
selection = input(self.menu)
if selection =="1":
# i go to the dictionary and access whats in the key "1"
# what i just accesed is my Grocery item
# I want you to extract the name nad price from the grocery item
# and the name to your shopping cart and then add your price to the total cost
pass
elif selection =="2":
pass
elif selection =="3":
pass
elif selection =="exit":
break
else:
print("invalid option try again")
def shopping_results(self):
pass
# print out everything in our list
# print out the total of price of our shopping cart
# print a thank you message
# call this function somewhere else
# create a GroceryStore1
# use the appplication_loop function with your grocerystore
trader_joes=GroceryStore1()
trader_joes.application_loop()