Flashcards
Untitled
Cards in this deck (1)
- 13-tier#!/usr/bin/env python
# -*- coding: utf-8 -*-
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):
""" Business logic holding data store instances """
data = Data()
def product_list(self):
return self.data['products'].keys()
def product_information(self, product):
return self.data['products'].get(product, None)
class Ui(object):
""" UI interaction class """
def __init__(self):
self.business_logic = BusinessLogic()
def get_product_list(self):
print('PRODUCT LIST:')
for product in self.business_logic.product_list():
print(product)
print('')
def get_product_information(self, product):
product_info = self.business_logic.product_information(product)
if prod
Information
- Description
- Flashcards on Untitled, created by Игорь Сергеевич on 29/07/2015.
- Created by
- Игорь Сергеевич
- Views
- 0
- Rating
More on Architectural Styles and Patterns