Appearance mode, implemented in python

Source: Internet
Author: User

 

Basic Description: The appearance mode does not change the structure of the original system. By creating the appearance class, the complex work of external interaction is provided.

Today, my boss has two jobs: 1. Arrange for a scan. 2. The security team is ready to receive the tour Delegation

The company's original organization has three departments A, B, and C.

In order to complete the tasks assigned by the boss, I had to act as the appearance class, arrange for A and C departments to scan the snow (the snow is very big and requires two departments), and arrange for B Department to receive the visit (B Department sister, sister can create an atmosphere)

[Python]
#-*-Coding: UTF-8 -*-
 
######################################## ###############
#
# Facade. py
# Python implementation of the Class client
# Generated by Enterprise effecect
# Created on: 12-December-2012 10:52:19
# Original author: zjm
#
######################################## ###############
 
 
 
From _ future _ import division
From _ future _ import print_function
From _ future _ import unicode_literals
From future_builtins import *

 
 
Class Department (object ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "None "):
Self. name = name
Pass
 
Def Operation (self ):
Print (self. name + "" + "does this work ")
Pass
 
Class internal menta (Department ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "DepartmentA "):
Super (DepartmentA, self). _ init _ (name)
Pass
 
Class DepartmentB (Department ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "DepartmentB "):
Super (DepartmentB, self). _ init _ (name)
Pass
 
Class DepartmentC (Department ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "DepartmentC "):
Super (DepartmentC, self). _ init _ (name)
Pass
 
Class Facade (object ):
"This class (a) knows which subsystem classes are responsible for a request, and
(B) delegates client requests to appropriate subsystem objects.
"""
M_DepartmentA = DepartmentA ()
M_DepartmentB = DepartmentB ()
M_DepartmentC = DepartmentC ()
Def _ init _ (self ):
Self. m_inclumenta = inclumenta ()
Self. m_DepartmentB = DepartmentB ()
Self. m_DepartmentC = DepartmentC ()


 
Def CleanSnow (self ):
Print ("CleanSnow :")
Self. m_DepartmentA.Operation ()
Self. m_DepartmentC.Operation ()

Pass
 
Def ReceiveVisit (self ):
Print ("ReceiveVisit :")
Self. m_DepartmentB.Operation ()
Pass
 
# Client (boss)
If (_ name __= = "_ main __"):

Class client:
M_Facade = Facade ()
M_Facade.CleanSnow ()
M_Facade.ReceiveVisit ()

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.