Exemple #1
0
        static void Main(string[] args)
        {
            Game game = new Game();

            /* Then you should generate four Blocks, each with a different weight, and Push, then into stack A.*/
            // Console.WriteLine("How many blocks for the game?");
            // int num = int.Parse(Console.ReadLine());
            // for (int i = num; i > 0; i--)
            // {
            //     Block b = new Block(i);
            //     game.towers["A"].blocks.Push(b);
            // }
            game.PrintBoard();

            bool won = false;

            while (!won)
            {
                Console.WriteLine("From what tower do you move a disk? A, B or C");
                string from = Console.ReadLine();
                Console.WriteLine("What tower do you want to move to? A, B or C");
                string to = Console.ReadLine();
                if (game.IsLegal(game.towers[from], game.towers[to]))
                {
                    game.MovePiece(game.towers[from], game.towers[to]);
                }
                else
                {
                    Console.WriteLine("It's an invalid input. Try again.");
                }
                //to access a key in a dictionary which is Tower

                game.PrintBoard();
                won = game.CheckforWin();
            }
        }