Ejemplo n.º 1
0
        public void EnterCommands()
        {
            bool CorrectCommand = false;

            while (!CorrectCommand)
            {
                string s = GetUserInput().ToLower();
                switch (s)
                {
                case "roll":
                    yatzy.Roll();
                    CorrectCommand = true;
                    yatzy.CallAllMethods();
                    break;

                case "hold":
                    EnterIntegersToHold();
                    CorrectCommand = true;
                    break;

                case "release":
                    yatzy.ReleaseAll();
                    break;

                case "reset":
                    yatzy.ResetAll();
                    break;

                case "help":
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("Mulige kommandoer: \n'roll' for at rulle terningerne. \n'hold' for at holde på terninger. \n'release' slipper de holdte terninger. \n'set biased' for at lave snydeterninger. \n'reset' for at lave terningerne fair igen. \n'save' for at gemme og strege et resultat. \n'print' for at vise score.");
                    Console.ResetColor();
                    break;

                case "set biased":
                    EnterBiased();
                    CorrectCommand = true;
                    break;

                case "cancel":
                    CorrectCommand = true;
                    break;

                case "print":
                    PrintScore();
                    break;

                case "save":
                    Save();
                    CorrectCommand = true;
                    break;

                default:
                    Console.Beep();
                    throw new InvalidCommandException($"Du har ikke skrevet en korrekt kommando (du skrev '{s}')");
                }
            }
        }