|
@@ -3,6 +3,7 @@
|
|
|
|
|
|
|
|
|
|
class Data(object):
|
|
class Data(object):
|
|
|
|
+ """ Data Store Class """
|
|
|
|
|
|
products = {
|
|
products = {
|
|
'milk': {'price': 1.50, 'quantity': 10},
|
|
'milk': {'price': 1.50, 'quantity': 10},
|
|
@@ -10,20 +11,26 @@ class Data(object):
|
|
'cheese': {'price': 2.00, 'quantity': 10}
|
|
'cheese': {'price': 2.00, 'quantity': 10}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ def __get__(self, obj, klas):
|
|
|
|
+ print ("(Fetching from Data Store)")
|
|
|
|
+ return {'products': self.products}
|
|
|
|
+
|
|
|
|
|
|
class BusinessLogic(object):
|
|
class BusinessLogic(object):
|
|
|
|
|
|
- def __init__(self):
|
|
|
|
- self.data = Data()
|
|
|
|
|
|
+ """ Business logic holding data store instances """
|
|
|
|
+
|
|
|
|
+ data = Data()
|
|
|
|
|
|
def product_list(self):
|
|
def product_list(self):
|
|
- return self.data.products.keys()
|
|
|
|
|
|
+ return self.data['products'].keys()
|
|
|
|
|
|
def product_information(self, product):
|
|
def product_information(self, product):
|
|
- return self.data.products.get(product, None)
|
|
|
|
|
|
+ return self.data['products'].get(product, None)
|
|
|
|
|
|
|
|
|
|
class Ui(object):
|
|
class Ui(object):
|
|
|
|
+ """ UI interaction class """
|
|
|
|
|
|
def __init__(self):
|
|
def __init__(self):
|
|
self.business_logic = BusinessLogic()
|
|
self.business_logic = BusinessLogic()
|
|
@@ -59,14 +66,19 @@ if __name__ == '__main__':
|
|
|
|
|
|
### OUTPUT ###
|
|
### OUTPUT ###
|
|
# PRODUCT LIST:
|
|
# PRODUCT LIST:
|
|
|
|
+# (Fetching from Data Store)
|
|
|
|
+# cheese
|
|
# eggs
|
|
# eggs
|
|
# milk
|
|
# milk
|
|
-# cheese
|
|
|
|
-#
|
|
|
|
|
|
+#
|
|
|
|
+# (Fetching from Data Store)
|
|
# PRODUCT INFORMATION:
|
|
# PRODUCT INFORMATION:
|
|
# Name: Cheese, Price: 2.00, Quantity: 10
|
|
# Name: Cheese, Price: 2.00, Quantity: 10
|
|
|
|
+# (Fetching from Data Store)
|
|
# PRODUCT INFORMATION:
|
|
# PRODUCT INFORMATION:
|
|
# Name: Eggs, Price: 0.20, Quantity: 100
|
|
# Name: Eggs, Price: 0.20, Quantity: 100
|
|
|
|
+# (Fetching from Data Store)
|
|
# PRODUCT INFORMATION:
|
|
# PRODUCT INFORMATION:
|
|
# Name: Milk, Price: 1.50, Quantity: 10
|
|
# Name: Milk, Price: 1.50, Quantity: 10
|
|
|
|
+# (Fetching from Data Store)
|
|
# That product "arepas" does not exist in the records
|
|
# That product "arepas" does not exist in the records
|