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

门面,系统,客户端~

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!

猜你喜欢

转载自www.cnblogs.com/aguncn/p/10749095.html
今日推荐