Skip to content

Commit

Permalink
Adding more verbose message for understanding, descriptor usage for l…
Browse files Browse the repository at this point in the history
…earning, and Fixed all errors/warning for PEP8
  • Loading branch information
arovit committed Apr 26, 2014
1 parent 1878a53 commit 2dfcb71
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions 3-tier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,34 @@


class Data(object):
""" Data Store Class """

products = {
'milk': {'price': 1.50, 'quantity': 10},
'eggs': {'price': 0.20, 'quantity': 100},
'cheese': {'price': 2.00, 'quantity': 10}
}

def __get__(self, obj, klas):
print "(Fetching from Data Store)"
return {'products': self.products}


class BusinessLogic(object):

def __init__(self):
self.data = Data()
""" Business logic holding data store instances """

data = Data()

def product_list(self):
return self.data.products.keys()
return self.data['products'].keys()

def product_information(self, product):
return self.data.products.get(product, None)
return self.data['products'].get(product, None)


class Ui(object):
""" UI interaction class """

def __init__(self):
self.business_logic = BusinessLogic()
Expand Down Expand Up @@ -59,14 +66,19 @@ def main():

### OUTPUT ###
# PRODUCT LIST:
# (Fetching from Data Store)
# cheese
# eggs
# milk
# cheese
#
#
# (Fetching from Data Store)
# PRODUCT INFORMATION:
# Name: Cheese, Price: 2.00, Quantity: 10
# (Fetching from Data Store)
# PRODUCT INFORMATION:
# Name: Eggs, Price: 0.20, Quantity: 100
# (Fetching from Data Store)
# PRODUCT INFORMATION:
# Name: Milk, Price: 1.50, Quantity: 10
# (Fetching from Data Store)
# That product "arepas" does not exist in the records

0 comments on commit 2dfcb71

Please sign in to comment.