コード例 #1
0
ファイル: Program.cs プロジェクト: rster2002/cs-csharp
        void start()
        {
            YahtzeeGame YahtzeeGame = new YahtzeeGame();

            //playYahtzeeGame(YahtzeeGame);
            playYahtzeeGameAdvanced(YahtzeeGame);
        }
コード例 #2
0
        void SpeelYahtzee(YahtzeeGame game)
        {
            int aantalpogingen = 0;

            do
            {
                game.Gooi();
                game.ToonWorp();

                aantalpogingen++;
            }while (!game.Yahtzee() && !game.FourOfAKind() && !game.ThreeOfAKind());

            // Ga na volgens de yahtzee hierarchie welke er is gegooid en hoe lang dat duurde
            if (game.Yahtzee())
            {
                Console.WriteLine("Aantal pogingen nodig voor Yahtzee: {0}", aantalpogingen);
            }
            else if (game.FourOfAKind())
            {
                Console.WriteLine("Aantal pogingen nodig voor Four Of A Kind: {0}", aantalpogingen);
            }
            else if (game.ThreeOfAKind())
            {
                Console.WriteLine("Aantal pogingen nodig voor Three Of A Kind: {0}", aantalpogingen);
            }
        }
コード例 #3
0
        private void Start()
        {
            YahtzeeGame yg = new YahtzeeGame();

            yg.Init();
            PlayYahtzee(yg);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            YahtzeeGame yahtzeeGame = new YahtzeeGame();

            yahtzeeGame.dice = new Dice[5];

            PlayYahtzee(yahtzeeGame);

            Console.ReadKey();
        }
コード例 #5
0
        private void PlayYahtzee(YahtzeeGame game)
        {
            int amountcount = 0;

            do
            {
                game.Throw();
                game.ShowValues();
                amountcount++;
            }while (!game.Yahtzee());
            Console.WriteLine("Aantal pogingen nodig voor yahtzee:{0}", amountcount);
            Console.ReadKey();
        }
コード例 #6
0
        static void PlayYahtzee(YahtzeeGame game)
        {
            int tries = 0;

            do
            {
                game.Throw();
                game.ShowValue();
                tries++;
            } while (!game.FourOfAKind());

            Console.WriteLine("Aantal pogingen nodig: " + tries);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: rster2002/cs-csharp
        void playYahtzeeGame(YahtzeeGame game)
        {
            int iterations = 0;

            do
            {
                game.roll();
                game.showResults();

                iterations++;
            } while (!game.yahtzee());

            Console.WriteLine($"Er waren {iterations} pogingen nodig voor yahtzee");
        }
コード例 #8
0
        void Start()
        {
            YahtzeeGame yahtzee        = new YahtzeeGame();
            int         aantalPogingen = 0;

            yahtzee.Init();

            do
            {
                yahtzee.Gooi();
                yahtzee.ToonWorp();

                aantalPogingen++;
            } while (!yahtzee.Yahtzee());

            Console.WriteLine($"Aantal pogingen: {aantalPogingen}");

            Console.ReadKey();
        }
コード例 #9
0
        void Start()
        {
            // Eerste deel

            /*   Dobbelsteen d1, d2;
             * d1 = new Dobbelsteen(); // dobbelsteen 1
             * d2 = new Dobbelsteen(); // dobbelsteen 2
             *
             * d1.Gooi();
             * d2.Gooi();
             *
             * d1.ToonWaarde();
             * d2.ToonWaarde();
             */

            // Tweede doel

            /* YahtzeeGame yahtzeeGame = new YahtzeeGame();
             * yahtzeeGame.Init();
             *
             * yahtzeeGame.Gooi();             // gooi
             * yahtzeeGame.ToonWorp();         // toon
             *
             * yahtzeeGame.Gooi();
             * yahtzeeGame.ToonWorp();
             */

            // echte doel
            YahtzeeGame yahtzeeGame = new YahtzeeGame();

            yahtzeeGame.Init();
            SpeelYahtzee(yahtzeeGame);  // speel het gemaakte spel


            Console.ReadKey();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: rster2002/cs-csharp
        void playYahtzeeGameAdvanced(YahtzeeGame game)
        {
            int iterations         = 0;
            int threeOfAKindCount  = 0;
            int fourOfAKindCount   = 0;
            int fullHousesCount    = 0;
            int smallStraightCount = 0;
            int fullStraightCount  = 0;

            int pointsScoredByThreeOfAKind   = 0;
            int pointsScoredByFourOfAKind    = 0;
            int pointsScoredByFullHouses     = 0;
            int pointsScoredBySmallStraights = 0;
            int pointsScoredByFullStraights  = 0;

            do
            {
                game.roll();

                Console.ForegroundColor = ConsoleColor.DarkGray;

                if (game.threeOfAKind())
                {
                    threeOfAKindCount++;
                    Console.ForegroundColor = ConsoleColor.DarkGreen;

                    pointsScoredByThreeOfAKind += game.diceValues.Sum();
                }

                if (game.fourOfAKind())
                {
                    fourOfAKindCount++;
                    Console.ForegroundColor = ConsoleColor.Green;

                    pointsScoredByFourOfAKind += game.diceValues.Sum();
                }

                if (game.fullHouse())
                {
                    fullHousesCount++;
                    Console.ForegroundColor = ConsoleColor.Blue;

                    pointsScoredByFullHouses += 25;
                }

                if (game.smallStraight())
                {
                    smallStraightCount++;
                    Console.ForegroundColor = ConsoleColor.Red;

                    pointsScoredBySmallStraights += 30;
                }

                if (game.fullStraight())
                {
                    fullStraightCount++;
                    Console.ForegroundColor = ConsoleColor.Magenta;

                    pointsScoredByFullStraights += 40;
                }

                game.showResults();
                iterations++;
            } while (!game.yahtzee());

            writeLineInColor(
                ConsoleColor.DarkGreen,
                $"Three of a kind: {threeOfAKindCount} ({pointsScoredByThreeOfAKind} punten)"
                );

            writeLineInColor(
                ConsoleColor.Green,
                $"Four of a kind: {fourOfAKindCount} ({pointsScoredByFourOfAKind} punten)"
                );

            writeLineInColor(
                ConsoleColor.Blue,
                $"Full houses: {fullHousesCount} ({pointsScoredByFullHouses} punten)"
                );

            writeLineInColor(
                ConsoleColor.Red,
                $"Small Straights: {smallStraightCount} ({pointsScoredBySmallStraights} punten)"
                );

            writeLineInColor(
                ConsoleColor.Magenta,
                $"Full Straights: {fullStraightCount} ({pointsScoredByFullStraights} punten)"
                );

            int totalPoints = pointsScoredByThreeOfAKind + pointsScoredByFourOfAKind + pointsScoredByFullHouses + pointsScoredBySmallStraights + pointsScoredByFullStraights + 50;


            Console.WriteLine($"Je heb in totaal {totalPoints} punten gescoord.");
            Console.WriteLine($"Er waren {iterations} pogingen nodig voor yahtzee");
        }