码迷,mamicode.com
首页 > 编程语言 > 详细

python设计模式---结构型之门面模式

时间:2019-04-22 11:59:57      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:def   nbsp   \n   car   ini   rri   设计模式   pytho   music   

门面,系统,客户端~

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设计模式---结构型之门面模式

标签:def   nbsp   \n   car   ini   rri   设计模式   pytho   music   

原文地址:https://www.cnblogs.com/aguncn/p/10749095.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!