Esempio n. 1
0
            public override void take_turn()
            {
                bool   valid      = false;
                bool   good_input = false;
                int    x;
                string s;

                while (!valid)
                {
                    do
                    {
                        Game.draw_map(g);
                        Console.Write("It's your turn.  Drop a token in which column? (1..7)>");
                        s = Console.ReadLine();
                        if (int.TryParse(s, out x))
                        {
                            if ((x >= 0) && (x <= 7
                                             ))
                            {
                                if (g.check_col(x - 1, g))
                                {
                                    good_input = true;
                                }
                                else    // if the column is full
                                {
                                    Console.Write("Column {0} is full.  Please choose another.\n", x);
                                }
                            }
                            else    //if not a number or in range
                            {
                                Console.Write("Please use the digits 1 through 7.\n");
                            }
                        }
                    } while (!good_input);
                    g.move(x - 1, Game.player);
                    valid = true;
                }
            }