Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions 3-tier.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def __get__(self, obj, klas):
class BusinessLogic(object):
""" Business logic holding data store instances """

data = Data()
def __init__(self, data):
self.data = data

def product_list(self):
return self.data['products'].keys()
Expand All @@ -31,8 +32,8 @@ def product_information(self, product):
class Ui(object):
""" UI interaction class """

def __init__(self):
self.business_logic = BusinessLogic()
def __init__(self, logic):
self.business_logic = logic

def get_product_list(self):
print('PRODUCT LIST:')
Expand All @@ -53,7 +54,9 @@ def get_product_information(self, product):


def main():
ui = Ui()
data = Data()
logic = BusinessLogic(data)
ui = Ui(logic)
ui.get_product_list()
ui.get_product_information('cheese')
ui.get_product_information('eggs')
Expand All @@ -69,7 +72,7 @@ def main():
# cheese
# eggs
# milk
#
#
# (Fetching from Data Store)
# PRODUCT INFORMATION:
# Name: Cheese, Price: 2.00, Quantity: 10
Expand Down