using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public abstract class Company
{
protected string name;
public Company(string name)
{
this.name = name;
}
public abstract void Add(Company c);
public abstract void Remove(Company c);
public abstract void Display(int depth);
public abstract void LineOfDuty();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class ConcreteCompany:Company
{
private List<Company> children = new List<Company>();
public ConcreteCompany(string name)
:base(name)
{}
public override void Add(Company c)
{
children.Add(c);
}
public override void Remove(Company c)
{
children.Remove(c);
}
public override void Display(int depth)
{
Console.WriteLine(new String('-',depth)+name);
foreach(Company component in children)
{
component.Display(depth+2);
}
}
public override void LineOfDuty()
{
foreach(Company component in children)
{
component.LineOfDuty();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class FinanceDepartment:Company
{
public FinanceDepartment(string name) : base(name) { }
public override void Add(Company c)
{
}
public override void Remove(Company c)
{
}
public override void Display(int depth)
{
Console.WriteLine(new String('-',depth)+name);
}
public override void LineOfDuty()
{
Console.WriteLine("{0} 财务支付管理",name);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class HRdepartment:Company
{
public HRdepartment(string name)
:base(name)
{ }
public override void Add(Company c)
{
}
public override void Remove(Company c)
{
}
public override void Display(int depth)
{
Console.WriteLine(new String('-',depth)+name);
}
public override void LineOfDuty()
{
Console.WriteLine("{0} 招聘培训管理",name);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
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);
root.Display(1);
Console.ReadKey();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有