门面,系统,客户端~

from django.test import TestCase

class Hotelier:
    def __init__(self):
        print('Arranging the Hotel for Marriage? ---')

    def _is_available(self):
        print('Is the Hotel free for the event on given dat?')
        return True

    def book_hotel(self):
        if self._is_available():
            print('Registered the Booking\n')

class Florist:
    def __init__(self):
        print('Flower Decorations for the Events? ---')

    def set_flower_requirements(self):
        print('Carnations, Roses and Lilies would be used for Decorations\n')

class Caterer:
    def __init__(self):
        print('Food Arrangements for the Event ---')

    def set_cuisine(self):
        print('Chinese & Continental Cuisine to be served\n')

class Musician:
    def __init__(self):
        print('Musical Arrangements for the Marriage ---')

    def set_music_type(self):
        print('Jazz and Classical will be played\n')

class EventManager:
    def __init__(self):
        print('Event Manager: Let me talk to the folks\n')

    def arrange(self):
        self.hotelier = Hotelier()
        self.hotelier.book_hotel()

        self.florist = Florist()
        self.florist.set_flower_requirements()

        self.caterer = Caterer()
        self.caterer.set_cuisine()

        self.musician = Musician()
        self.musician.set_music_type()

class You:
    def __init__(self):
        print('Your:: Whoa! Marriage Arrangements???!!!')

    def ask_event_manager(self):
        print('You:: Let us Contack the Event Manager\n')
        em = EventManager()
        em.arrange()

    def __del__(self):
        print('Your:: Thanks to Event Manager, all preparations done! Phew!')

you = You()
you.ask_event_manager()
Your:: Whoa! Marriage Arrangements???!!!
You:: Let us Contack the Event Manager

Event Manager: Let me talk to the folks

Arranging the Hotel for Marriage? ---
Is the Hotel free for the event on given dat?
Registered the Booking

Flower Decorations for the Events? ---
Carnations, Roses and Lilies would be used for Decorations

Food Arrangements for the Event ---
Chinese & Continental Cuisine to be served

Musical Arrangements for the Marriage ---
Jazz and Classical will be played

Your:: Thanks to Event Manager, all preparations done! Phew!

python设计模式---结构型之门面模式的更多相关文章

  1. python设计模式---结构型之代理模式

    主要想着nginx:) from abc import ABCMeta, abstractmethod # 结构型设计模式---代理模式 class Actor: def __init__(self) ...

  2. JAVA设计模式 5【结构型】代理模式的理解与使用

    今天要开始我们结构型 设计模式的学习,设计模式源于生活,还是希望能通过生活中的一些小栗子去理解学习它,而不是为了学习而学习这些东西. 结构型设计模式 结构型设计模式又分为 类 结构型 对象 结构型 前 ...

  3. 【结构型】Flyweight模式

    享元模式的主要目的.意图是为对象的大量使用提供一种共享机制.该模式的思想重在复用.共享复用.像文字.列表中的格子等这类多数都是需要考虑复用技术,否则必将大量耗费内存空间而使资源以及性能等大量耗费.该模 ...

  4. python设计模式之模型-视图-控制器模式

    python设计模式之模型-视图-控制器模式 关注点分离( Separation of Concerns, SoC)原则是软件工程相关的设计原则之一. SoC原则背后的思想是将一个应用切分成不同的部分 ...

  5. 设计模式-结构型模式,python组合模式

    设计模式上大的方向上分继承和组合,就是类模式和对象模式.此篇的组合模式非继承和组合概念中的组合.桥接 策略 代理 装饰者都用了组合,此组合非彼组合. 组合模式 组合模式(Composite Patte ...

  6. 设计模式-结构型模式,python桥接模式

    桥接模式 桥接(Bridge)是用于把抽象化与实现化解耦,使得二者可以独立变化.这种类型的设计模式属于结构型模式,它通过提供抽象化和实现化之间的桥接结构,来实现二者的解耦. 这种模式涉及到一个作为桥接 ...

  7. 设计模式 结构型模式 外观模式(Facade Pattern)

    在软件开发过程中,客户端程序经常会与复杂系统的内部子系统进行耦合,从而导致客户端程序随着子系统的变化而变化. 这时为了将复杂系统的内部子系统与客户端之间的依赖解耦,从而就有了外观模式,也称作 ”门面“ ...

  8. Java设计模式——结构型模式

    Java设计模式中共有7种结构型模式:适配器模式.装饰模式.代理模式.外观模式.桥接模式.组合模式.享元模式.其中对象的适配器模式是各种模式的起源,其关系如下面的图:1.适配器模式 适配器模式将某个类 ...

  9. 【设计模式】结构型03外观模式(Facade Pattern)

    [设计模式]结构型02装饰模式(Decorator Pattern) 意图:为子系统中的一组接口提供一个一致的界面,外观模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 主要解决:降低访问 ...

随机推荐

  1. c语言提高第二天

    一.指针强化1.指针也是一种数据类型,指针变量也是一种变量,和int a本质是一样的 1)指针变量也是一种变量,也有空间,32位程序大小为4个字节 int *p = 0x1122; 2)*操作符,*相 ...

  2. Windows + Ubuntu 16.04 双系统安装详细教程

    Windows + Ubuntu 16.04 双系统安装详细教程 2018年01月28日 16:43:19 flyyufenfei 阅读数:165619   发现了一篇好教程,果断转载了,以后用得着时 ...

  3. 洛谷P2634 聪明可可

    还是点分治 树上问题真有趣ovo,这道题统计模3为0的距离,可以把重心的子树分开统计,也可以一次性统计,然后容斥原理减掉重复的.. 其他的过程就是点分治的板子啦. #include <bits/ ...

  4. mysql 如何优化left join

    今天遇到一个left join优化的问题,搞了一下午,中间查了不少资料,对MySQL的查询计划还有查询优化有了更进一步的了解,做一个简单的记录: select c.* from hotel_info_ ...

  5. 【XSY3147】子集计数 DFT 组合数学

    题目大意 给定一个集合 \(\{1,2,\ldots,n\}\),要求你从中选出 \(m\) 个数,且这 \(m\) 个数的和是 \(k\).问方案数 \(\bmod 998244353\) \(0\ ...

  6. 【转】Esp8266学习之旅① 搭建开发环境,开始一个“hellow world”串口打印。

    @2019-02-28 [小记] Esp8266学习之旅① 搭建开发环境,开始一个“hellow world”串口打印.

  7. luogu3346 诸神眷顾的幻想乡 (广义SAM)

    首先,让每一个叶节点做一次树根的话,每个路径一定至少有一次会变成直上直下的 于是对于每个叶节点作为根产生的20个trie树,把它们建到同一个广义SAM里 建法是对每个trie dfs去建,last就是 ...

  8. 求一个数组中重复数字的个数,要求复杂度为O(n)

    给出代码 #include <stdio.h> #include <unistd.h> #include <iostream> #include <memor ...

  9. Awesome CLI

    请移步https://github.com/zhuxiaoxi/awesome-online-tools 欢迎一同维护这个列表 jq JSON工具 shellcheck 更好用的Shell语法检查 c ...

  10. Numpy 系列(七)- 常用函数

    在了解了 Numpy 的基本运算操作,下面来看下 Numpy常用的函数.     数学运算函数 add(x1,x2 [,out]) 按元素添加参数,等效于 x1 + x2 subtract(x1,x2 ...