'I am trying to make a basic Grocery Store without prices
class Toptanci:
def __init__(self):
self.fruits = dict(apple=30, pear=40, cherry=20, banana=10, strawberry=15)
self.vegetables = dict(garlic=40, Tomatoes=30, Eggplant=40, Onion=25, Potato=15)
self.all_list = self.fruits and self.vegetables ## YANLIS OLABILIR !
def report(self): ### RAPOR
print(self.fruits and self.vegetables)
def is_resource_sufficient(self, purchase): ### YETERLI VAR MI DIYE BAK
can_purchase = True
for item in purchase.all_list:
if purchase.all_list[item] > self.all_list[item]:
print(f"Sorry there is not enough {item}")
can_purchase = False
return can_purchase
def order_purchase(self, order): ### GEREKLI AMOUNUT"U CIKAR
for item in order.all_list:
self.all_list[item] -= order.all_list[item]
print(f"Here is your {order}")
def main(self):
question1 = input("Fruits or Vegetables?").lower()
question2 = int(input("Please enter the KG amount you want ="))
question3 = input("Would you like something else? 'y' or 'n'").lower()
if question1 == 'fruits':
print(question2)
Basically, I am trying to get input from the user and deduct the amount from the base values. In addition, I want to add the amount I get from the Toptanci class into the Manav class. So when in Manav section the amount gathered will be added. In the Manav Class we should have the amount of vegetable or fruits bought and it should display the bought amount. So when another user tries to buy from Manav. It will see Manav's stock and the stock will be reduced accordingly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
