示例#1
0
        static void Main(string[] args)
        {
            // stream example, you can put a StreamWriter in an EncryptedStream and write an encrypted text to somewhere.
            // https://en.wikipedia.org/wiki/Decorator_pattern
            var player = new Player("Ken", Console.Out);
            player.Play();

            var quester = new QuestingPlayer(player);
            var fighter = new FightingPlayer(quester);
            fighter.Play();

            Console.WriteLine("{0} stopped questing.", player.Name);
            fighter = new FightingPlayer(player);
            fighter.Play();

            Console.WriteLine(player.ToString());
            Console.ReadLine();
        }
示例#2
0
 public Player(Player player)
 {
     Writer = player.Writer;
     Name = player.Name;
     Level = player.Level;
 }
示例#3
0
 public SellingPlayer(Player player)
     : base(player)
 {
     _player = player;
 }
示例#4
0
 public FightingPlayer(Player player)
     : base(player)
 {
     _player = player;
 }
示例#5
0
 public QuestingPlayer(Player player)
     : base(player)
 {
     _player = player;
 }