private static void Main(string[] args) { //初始化 AbstractPlayer someM = new SomgM(); AbstractPlayer nvShen = new NvShen(); //初始金钱 someM.Money = 20; nvShen.Money = 20; //初始中介者,初始平局状态 AbstractMediator mediator = new MediatorPater(new Init()); //女神和小明,加入游戏 mediator.Enter(someM); mediator.Enter(nvShen); //小明赢了 mediator.State = new AWin(mediator); mediator.Change(10); //女神赢了 mediator.State = new BWin(mediator); mediator.Change(5); //双方的钱 Console.WriteLine("小明 现在钱:{0}", someM.Money); Console.WriteLine("女神 现在钱:{0}", nvShen.Money); Console.ReadLine(); }
private static void Main(string[] args) { //初始化 AbstractPlayer someM = new SomgM(); AbstractPlayer nvShen = new NvShen(); //初始金钱 someM.Money = 20; nvShen.Money = 20; //初始中介者,初始平局状态 AbstractMediator mediator = new MediatorPater(new Init()); //女神和小明,加入游戏 mediator.Enter(someM); mediator.Enter(nvShen); //小明赢了 mediator.State = new AWin(mediator); mediator.Change(10); //女神赢了 mediator.State = new BWin(mediator); mediator.Change(5); //双方的钱 Console.WriteLine("小明 现在钱:{0}", someM.Money); Console.WriteLine("女神 现在钱:{0}", nvShen.Money); Console.ReadLine(); }