Esempio n. 1
0
        static void Main(string[] args)
        {
            BeaverHouse House = new BeaverHouse();

            House.beaverKing.Name = "King!";
            House.beaverOne.Name  = "Barbara";
            House.beaverTwo.Name  = "Twix";

            var commands = new Dictionary <ConsoleKey, ICommand>()
            {
                [ConsoleKey.D1]     = new ShowTrash(House),
                [ConsoleKey.D2]     = new GiveBeaverTrash(House),
                [ConsoleKey.Escape] = new Exit()
            };

            while (isMenu)
            {
                Console.WriteLine("\nPress 1 - ShowTrashAndBeaver 2 - TakeTrash, Escape - Exit\n");
                var key = Console.ReadKey().Key;

                if (commands.ContainsKey(key))
                {
                    Console.Clear();
                    var selectCommand = commands[key];
                    selectCommand.Act();
                }
                else
                {
                    Console.Clear();
                }
            }
        }
Esempio n. 2
0
 public GiveBeaverTrash(BeaverHouse house)
 {
     this.house = house;
 }
Esempio n. 3
0
 public ShowTrash(BeaverHouse house)
 {
     this.house = house;
 }