Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class InventoryProduct():
- def __init__(self, name, price, stock_amount):
- self.name = name
- self.price = price
- self.stock_amount = stock_amount
- class BasketProduct(InventoryProduct):
- def __init__(self, name, price, stock_amount, basket_amount):
- super.__init__(name, price, stock_amount)
- self.basket_amount = basket_amount
- class Basket():
- def __init__(self):
- self.contents = dict()
- self.total_value = 0.0
- def display_contents(self):
- #self.contents dict indeki keyleri dolaşarak basket teki ürünleri göster
- pass
- def show_basket_submenu(self):
- #arama vs. olan menüyü göster.buralar biraz copy paste şeklinde halledersin
- pass
- def add_item(self, product):
- #kullanıcıdan stok kontrolu yaparak sayıyı al amount a ata
- amount = 0
- temp_basket_product = BasketProduct(product.name,
- product.price,
- product.stock_amount,
- amount)
- self.contents[product.name] = temp_basket_product
- self.total_value += product.price * amount
- def remove_item(self):
- #kullanıcıdan kaldırılacak ürünün adını al product a ata
- product = ""
- value = self.contents[product].price * self.contents[product].basket_amount
- self.contents.pop(product)
- self.total_value -= value
- def update_item(self):
- #kullanıcıdan update edilecek ürünün adını ve miktarını al
- product = ""
- amount = 0
- old_value = self.contents[product].price * self.contents[product].basket_amount
- self.contents[product].basket_amount = amount
- self.total_value += (amount * self.contents[product].price - old_value)
- class User():
- def __init__(self, username, password, basket):
- self.username = username
- self.password = password
- self.basket = basket
- class Market():
- def __init__(self):
- temp_inv_dict = {'asparagus':[1,2],'broccoli':[15,6],'carrots':[18,7], 'apples':[20,5],'banana':[10,8],'berries':[30,3], 'eggs':[50,2],'mixed fruit juice':[0,8],'fish sticks':[25,12], 'ice cream':[32,6], 'apple juice':[40,7], 'orange juice':[30,8], 'grape juice':[10,9]}
- self.inventory = dict()
- for k in temp_inv_dict.keys():
- temp_inventory_product = InventoryProduct(k,
- temp_inv_dict[k][1],
- temp_inv_dict[k][0])
- self.inventory[k] = temp_inventory_product
- temp_user_dict = {"ahmet":"sehir123","meryem":"4444","a":"b"}
- self.users = dict()
- for k in temp_user_dict.keys():
- temp_basket = Basket()
- temp_user = User(k, temp_user_dict[k], temp_basket)
- self.users[k] = temp_user
- def show_market_menu(self, user):
- #market menüsü neyse onu göster ve seçilen durumlara göre gerekli
- #fonksiyonu çağır
- pass
- def search(self, user):
- #user için ürün araması. copy paste
- pass
- def update_stock(self, product_name, sold_amount):
- self.inventory[product_name] -= sold_amount
- def check_out(self, user):
- #en sonda yaptığın müşteri çıkışı olayı copy paste
- pass
- def print_receipt(self, basket):
- #bu baskette olan ürünleri gösterirsin (basket objesinin display contents metodunu kullanırsın)
- pass
- def login(self):
- #kullanıcıdan username ve password alıp login kontolü yap
- username = ""
- return self.users[username]
- def initialize_market(self):
- self.show_market_menu(self.login())
- market = Market()
- market.initialize_market()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement