using System;
using System.Collections.Generic;
using System.Text;
//工厂模式
namespace designMode
{
class LeiFeng
{
public void Sweep()
{
Console.WriteLine("扫地");
}
public void Wash()
{
Console.WriteLine("洗衣");
}
public void BuyRice()
{
Console.WriteLine("买米");
}
}
class Undergraduate : LeiFeng
{
}
class Volunteer : LeiFeng
{
}
interface IFactory
{
LeiFeng CreateLeiFeng();
}
class UndergraduateFactory : IFactory
{
public LeiFeng CreateLeiFeng()
{
return new Undergraduate();
}
}
class VolunteerFactory : IFactory
{
public LeiFeng CreateLeiFeng()
{
return new Volunteer();
}
}
}
static void Main(string[] args)
{
//工厂模式
IFactory factory = new UndergraduateFactory();
LeiFeng student = factory.CreateLeiFeng();
student.BuyRice();
student.Sweep();
student.Wash();
Console.Read();
}