Exemple #1
0
        static void Main(string[] args)
        {
            ConcreteCompany root = new ConcreteCompany("北京总公司");
            root.Add(new HrDepartment("总公司人力资源部"));
            root.Add(new FinanceDepartment("总公司财务部"));

            ConcreteCompany comp = new ConcreteCompany("上海华东分公司");
            comp.Add(new HrDepartment("华东分公司人力资源部"));
            comp.Add(new FinanceDepartment("华东分公司财务部"));
            root.Add(comp);

            ConcreteCompany comp1 = new ConcreteCompany("南京办事处");
            comp1.Add(new HrDepartment("南京办事处人力资源部"));
            comp1.Add(new FinanceDepartment("南京办事处财务部"));
            comp.Add(comp1);

            ConcreteCompany comp2 = new ConcreteCompany("杭州办事处");
            comp2.Add(new HrDepartment("杭州办事处人力资源部"));
            comp2.Add(new FinanceDepartment("杭州办事处财务部"));
            comp.Add(comp2);

            Console.WriteLine("\n结构图:");
            root.Display(1);

            Console.WriteLine("\n职责:");
            root.LineOfDuty();

            Console.Read();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ConcreteCompany root = new ConcreteCompany("北京总公司");

            root.Add(new HrDepartment("总公司人力资源部"));
            root.Add(new FinanceDepartment("总公司财务部"));

            ConcreteCompany comp = new ConcreteCompany("上海华东分公司");

            comp.Add(new HrDepartment("华东分公司人力资源部"));
            comp.Add(new FinanceDepartment("华东分公司财务部"));
            root.Add(comp);

            ConcreteCompany comp1 = new ConcreteCompany("南京办事处");

            comp1.Add(new HrDepartment("南京办事处人力资源部"));
            comp1.Add(new FinanceDepartment("南京办事处财务部"));
            comp.Add(comp1);

            ConcreteCompany comp2 = new ConcreteCompany("杭州办事处");

            comp2.Add(new HrDepartment("杭州办事处人力资源部"));
            comp2.Add(new FinanceDepartment("杭州办事处财务部"));
            comp.Add(comp2);

            Console.WriteLine("\n结构图:");
            root.Display(1);

            Console.WriteLine("\n职责:");
            root.LineOfDuty();

            Console.Read();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            ConcreteCompany root = new ConcreteCompany("總公司");

            root.Add(new HRDepartment("總公司人資部門"));
            root.Add(new FinanceDepartment("總公司財務部門"));

            ConcreteCompany comp = new ConcreteCompany("A分公司");

            comp.Add(new HRDepartment("A分公司人資部門"));
            comp.Add(new FinanceDepartment("A分公司財務部門"));
            root.Add(comp);

            ConcreteCompany comp1 = new ConcreteCompany("A分公司子公司");

            comp1.Add(new HRDepartment("A分公司子公司人資部門"));
            comp1.Add(new FinanceDepartment("A分公司子公司財務部門"));
            comp.Add(comp1);


            ConcreteCompany comp2 = new ConcreteCompany("B分公司");

            comp2.Add(new HRDepartment("B分公司人資部門"));
            comp2.Add(new FinanceDepartment("B分公司財務部門"));
            root.Add(comp2);

            Console.WriteLine("\n公司組織圖:");
            root.Display(1);

            Console.WriteLine("\n公司職責:");
            root.LineOfDuty();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            ConcreteCompany root = new ConcreteCompany("深圳总公司");

            root.Add(new HRDepartment("深圳总公司人力资源部"));
            root.Add(new FinanceDepartment("总公司财务部"));

            ConcreteCompany comp = new ConcreteCompany("湖南分公司");

            comp.Add(new HRDepartment("湖南分公司人力资源部"));
            comp.Add(new FinanceDepartment("湖南分公司财务部"));
            root.Add(comp);

            ConcreteCompany comp1 = new ConcreteCompany("上海分公司");

            comp1.Add(new HRDepartment("上海分公司人力资源部"));
            comp1.Add(new FinanceDepartment("上海分公司财务部"));
            root.Add(comp1);

            System.Console.WriteLine("结构图:");
            root.Display(1);

            System.Console.WriteLine("职责:");
            root.LineOfDuty();
        }
Exemple #5
0
        private static void Main(string[] args)
        {
            ConcreteCompany root = new ConcreteCompany("總公司");

            root.Add(new HRDepartment("總公司人力資源部"));
            root.Add(new FinanceDepartment("總公司財務部"));
            ConcreteCompany comp = new ConcreteCompany("分公司");

            comp.Add(new HRDepartment("分公司人力資源部"));
            comp.Add(new FinanceDepartment("分公司財務部"));
            root.Add(comp);

            ConcreteCompany comp1 = new ConcreteCompany("辦事處");

            comp1.Add(new HRDepartment("辦事處人力資源部"));
            comp1.Add(new FinanceDepartment("辦事處財務部"));
            root.Add(comp1);

            ConcreteCompany comp2 = new ConcreteCompany("代表處");

            comp2.Add(new HRDepartment("代表處人力資源部"));
            comp2.Add(new FinanceDepartment("代表處財務部"));
            root.Add(comp2);

            Console.WriteLine("結構圖");
            root.Display(1);

            Console.WriteLine("職責");
            root.LineOfDuty();

            Console.Read();
        }
Exemple #6
0
        static void Main(string[] args)
        {
            #region Simple Display
            //Composite root = new Composite("root");

            //root.Add(new Leaf("Leaf A"));
            //root.Add(new Leaf("Leaf B"));

            //Composite comp = new Composite("Composite X");
            //comp.Add(new Leaf("Leaf XA"));
            //comp.Add(new Leaf("Leaf XB"));

            //root.Add(comp);

            //Composite comp2 = new Composite("Composite XY");
            //comp2.Add(new Leaf("Leaf XYA"));
            //comp2.Add(new Leaf("Leaf XYB"));
            //comp.Add(comp2);

            //root.Add(new Leaf("Leaf C"));

            //Leaf leaf = new Leaf("Leaf D");

            //root.Add(leaf);

            ////root.Remove(leaf);

            //root.Display(1);
            #endregion

            //部门
            ConcreteCompany root = new ConcreteCompany("北京总公司");
            root.Add(new HRDepartment("总公司人力资源部"));
            root.Add(new FinanceCompany("总公司财务部"));

            ConcreteCompany comp = new ConcreteCompany("上海华东分公司");
            comp.Add(new HRDepartment("华东分公司人力资源部"));
            comp.Add(new FinanceCompany("华东分公司财务部"));
            root.Add(comp);

            ConcreteCompany comp1 = new ConcreteCompany("南京办事处");
            comp1.Add(new HRDepartment("南京办事处人力资源部"));
            comp1.Add(new FinanceCompany("南京办事处财务部"));
            root.Add(comp1);

            ConcreteCompany comp2 = new ConcreteCompany("杭州办事处");
            comp2.Add(new HRDepartment("杭州办事处人力资源部"));
            comp2.Add(new FinanceCompany("杭州办事处财务部"));
            root.Add(comp2);

            Console.WriteLine();
            Console.WriteLine("结构图");

            root.Display(1);

            root.LineOfDuty();
            Console.Read();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            //在北京是总部 有人力资源和财务部 两大部门
            ConcreteCompany beijing = new ConcreteCompany("北京总部");

            beijing.Add(new HRDepartment("北京人力资源"));
            beijing.Add(new FinanceDepartment("北京财务部"));

            //在伤害是一个分公司  也有他的人力资源和财务部
            ConcreteCompany shanghai = new ConcreteCompany("上海分公司");

            shanghai.Add(new HRDepartment("上海人力资源"));
            shanghai.Add(new FinanceDepartment("上海财务部"));

            //在南京只是一个办事处  只有人力资源部
            ConcreteCompany nanjing = new ConcreteCompany("南京办事处");

            nanjing.Add(new HRDepartment("南京人力资源"));

            //在杭州也是一个办事处 也同时只有财务部
            ConcreteCompany hangzhou = new ConcreteCompany("杭州办事处");

            hangzhou.Add(new FinanceDepartment("杭州财务中心"));

            //南京和杭州离上海比较近  归属上海管
            shanghai.Add(nanjing);
            shanghai.Add(hangzhou);

            //当然了 上海分公司也是归属北京总部管的
            beijing.Add(shanghai);

            beijing.Display(2);
            beijing.LineOfDuty();

            Console.WriteLine("\r\n南京的招不到人,上海分公司将其解散了\r\n");
            shanghai.Remove(nanjing);

            beijing.Display(2);
            beijing.LineOfDuty();

            Console.Read();
        }
Exemple #8
0
        static void Main(string[] args)
        {
            // 测试类(Client):三个公司,阿里巴巴、淘宝、阿里云,
            // 其中,淘宝和阿里云是阿里巴巴的子公司,
            // 同时,每个公司又有自己的研发部门和人资部门。
            Company alibaba = new ConcreteCompany("Alibaba", "B2B");
            Company taobao  = new ConcreteCompany("Taobao", "C2C");
            Company aliyun  = new ConcreteCompany("Aliyun", "Cloud Compution");

            Company aliHrDepartment       = new Department("Alibaba HR Department");
            Company aliResearchDepartment = new Department("Alibaba RESEARCH Department");

            Company taobaoHrDepartment       = new Department("Taobao HR Department");
            Company taobaoResearchDepartment = new Department("Taobao RESEARCH Department");

            Company aliyunHrDepartment       = new Department("Aliyun HR Department");
            Company aliyunResearchDepartment = new Department("Aliyun RESEARCH Department");

            alibaba.Add(taobao);
            alibaba.Add(aliyun);
            alibaba.Add(aliHrDepartment);
            alibaba.Add(aliResearchDepartment);

            taobao.Add(taobaoHrDepartment);
            taobao.Add(taobaoResearchDepartment);

            aliyun.Add(aliyunHrDepartment);
            aliyun.Add(aliyunResearchDepartment);

            alibaba.Display(0);
            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~\n");
            taobao.Display(0);
            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~\n");
            aliyun.Display(0);
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            ConcreteCompany companyRoot = new ConcreteCompany("北京總公司");

            companyRoot.Add(new HRDepartment("總公司人力資源部"));
            companyRoot.Add(new FinanceDepartment("總公司財務部"));

            ConcreteCompany companyA = new ConcreteCompany("上海華東分公司");

            companyA.Add(new HRDepartment("華東分公司人力資源部"));
            companyA.Add(new FinanceDepartment("華東分公司財務部"));
            companyRoot.Add(companyA);

            ConcreteCompany companyB = new ConcreteCompany("南京辦事處");

            companyB.Add(new HRDepartment("南京辦事處人力資源部"));
            companyB.Add(new FinanceDepartment("南京辦事處財務部"));
            companyA.Add(companyB);

            ConcreteCompany companyC = new ConcreteCompany("杭州辦事處");

            companyC.Add(new HRDepartment("杭州辦事處人力資源部"));
            companyC.Add(new FinanceDepartment("杭州辦事處財務部"));
            companyA.Add(companyC);

            Console.WriteLine("組織結構圖");
            companyRoot.Display(1);

            Console.WriteLine("\n職責");
            companyRoot.LineOfDuty();

            Console.WriteLine("\n");

            Composite root = new Composite("root");

            root.Add(new Leaf("Leaf A"));
            root.Add(new Leaf("Leaf B"));

            Composite comp = new Composite("Composite X");

            comp.Add(new Leaf("Leaf XA"));
            comp.Add(new Leaf("Leaf XB"));

            root.Add(comp);

            Composite comp2 = new Composite("Composite XY");

            comp2.Add(new Leaf("Leaf XYA"));
            comp2.Add(new Leaf("Leaf XYB"));

            comp.Add(comp2);

            root.Add(new Leaf("Leaf C"));

            Leaf leafD = new Leaf("Leaf D");

            root.Add(leafD);
            root.Remove(leafD);

            root.Display(1);

            Console.ReadLine();
        }