using System;
namespace Factory1
{
//雷锋基类
class LeiFeng
{
public void Sweep()
{
Console.Writeline ("sweep");
}
public void Wash()
{
Console.Writeline ("Wash");
}
public void BugRice()
{
Console.WriteLine ("BugRice");
}
}
//学雷锋的大学生类
class Undergraduate:LeiFeng
{
}
//学雷锋的志愿者类
class Voluntieer:LeiFeng
{
}
//雷锋 工厂类
interface IFactory
{
LeiFeng CreateLeiFeng();
}
//大学生 工厂类
class UndergraduateFactory:IFactory
{
public LeiFeng CreateLeiFeng()
{
return new Undergraduate ();
}
}
//志愿者 工厂类
class VolenteerFactory:IFactory
{
public LeiFeng CreateLeiFeng()
{
return new Undergraduate ();
}
}
class MainClass
{
public static void Main (string[] args)
{
IFactory factory = new UndergraduateFactory ();
LeiFeng student = factory.CreateLeiFeng ();
student.BugRice();
student.Sweep ();
student.Wash ();
}
}
}