public interface MiaoMoudle
{
void WritStr();
}
public interface AddMoudle
{
void AddMiaoMoudle(MiaoMoudle MiaoMiMi);
}
public class Cat
{
private List<MiaoMoudle> ListMiao = null;
public Cat()
{
ListMiao = new List<MiaoMoudle>();
}
public void AddCat(MiaoMoudle mm)
{
ListMiao.Add(mm);
}
public void CatCry()
{
Console.WriteLine("猫叫了喵喵");
foreach (MiaoMoudle item in ListMiao)
{
item.WritStr();
}
}
}
public class Mouse : MiaoMoudle
{
public Mouse(Cat cat)
{
cat.AddCat(this);
}
public void WritStr()
{
Console.WriteLine("老鼠跑了");
}
}
public class People : MiaoMoudle
{
public People(Cat cat)
{
cat.AddCat(this);
}
public void WritStr()
{
Console.WriteLine("人醒了");
}
}
public class Cat1
{
public delegate void CatCry();
public event CatCry OnCatCry = null;
public void CatMiaoMiao()
{
Console.WriteLine("喵喵叫");
OnCatCry();
}
}
public class Mouse1
{
public delegate void MouseRuning();
public event MouseRuning OnMouseRuning = null;
public Mouse1(Cat1 cat)
{
cat.OnCatCry += MouseRun;
}
public void MouseRun()
{
Console.WriteLine("老鼠跑了");
OnMouseRuning();
}
}
public class People1
{
public People1(Mouse1 mouse)
{
mouse.OnMouseRuning += PeopleXing;
}
public void PeopleXing()
{
Console.WriteLine("人醒了");
}
}
class Program
{
static void Main(string[] args)
{
Cat cat = new Cat();
Mouse mouse = new Mouse(cat);
People people = new People(cat);
cat.CatCry();
Cat1 cat1 = new Cat1();
Mouse1 mouse1 = new Mouse1(cat1);
People1 people1 = new People1(mouse1);
cat1.CatMiaoMiao();
Console.ReadLine();
}
}
{
void WritStr();
}
public interface AddMoudle
{
void AddMiaoMoudle(MiaoMoudle MiaoMiMi);
}
public class Cat
{
private List<MiaoMoudle> ListMiao = null;
public Cat()
{
ListMiao = new List<MiaoMoudle>();
}
public void AddCat(MiaoMoudle mm)
{
ListMiao.Add(mm);
}
public void CatCry()
{
Console.WriteLine("猫叫了喵喵");
foreach (MiaoMoudle item in ListMiao)
{
item.WritStr();
}
}
}
public class Mouse : MiaoMoudle
{
public Mouse(Cat cat)
{
cat.AddCat(this);
}
public void WritStr()
{
Console.WriteLine("老鼠跑了");
}
}
public class People : MiaoMoudle
{
public People(Cat cat)
{
cat.AddCat(this);
}
public void WritStr()
{
Console.WriteLine("人醒了");
}
}
public class Cat1
{
public delegate void CatCry();
public event CatCry OnCatCry = null;
public void CatMiaoMiao()
{
Console.WriteLine("喵喵叫");
OnCatCry();
}
}
public class Mouse1
{
public delegate void MouseRuning();
public event MouseRuning OnMouseRuning = null;
public Mouse1(Cat1 cat)
{
cat.OnCatCry += MouseRun;
}
public void MouseRun()
{
Console.WriteLine("老鼠跑了");
OnMouseRuning();
}
}
public class People1
{
public People1(Mouse1 mouse)
{
mouse.OnMouseRuning += PeopleXing;
}
public void PeopleXing()
{
Console.WriteLine("人醒了");
}
}
class Program
{
static void Main(string[] args)
{
Cat cat = new Cat();
Mouse mouse = new Mouse(cat);
People people = new People(cat);
cat.CatCry();
Cat1 cat1 = new Cat1();
Mouse1 mouse1 = new Mouse1(cat1);
People1 people1 = new People1(mouse1);
cat1.CatMiaoMiao();
Console.ReadLine();
}
}