public static void Main(string[] argv)
        {
            // You have a `DiceSet` class which has a list for 6 dice
            // You can roll all of them with roll()
            // Check the current rolled numbers with getCurrent()
            // You can reroll with reroll()
            // Your task is to roll the dice until all of the dice are 6
            DiceSet diceSet = new DiceSet();

            diceSet.Roll();
            foreach (var value in diceSet.GetCurrent())
            {
                Console.Write($"{value} ");
            }
            Console.WriteLine();

            for (int i = 0; i < diceSet.GetCurrent().Length; i++)
            {
                do
                {
                    diceSet.Reroll(i);
                    foreach (var value in diceSet.GetCurrent())
                    {
                        Console.Write($"{value} ");
                    }
                    Console.WriteLine();
                } while (diceSet.GetCurrent(i) != 6);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            // You have a `DiceSet` class which has a list for 6 dice
            // You can roll all of them with roll()
            // Check the current rolled numbers with getCurrent()
            // You can reroll with reroll()
            // Your task is to roll the dice until all of the dice are 6
            DiceSet diceSet = new DiceSet();

            /*
             * Console.WriteLine(diceSet.GetCurrent());
             * diceSet.Roll();
             * Console.WriteLine(diceSet.GetCurrent());
             * Console.WriteLine(diceSet.GetCurrent(5));
             * diceSet.Reroll();
             * Console.WriteLine(diceSet.GetCurrent());
             * diceSet.Reroll(4);
             * Console.WriteLine(diceSet.GetCurrent());
             */

            // SOLUTION 1 //
            diceSet.Roll();
            int diceSum = 0;

            for (int i = 0; i < 6; i++)
            {
                diceSum += diceSet.GetCurrent(i);
            }
            if (diceSum == 36)
            {
                Console.WriteLine("All the dices are 6");
            }
            else
            {
                diceSet.Reroll();
            }

            // SOLUTION 2 //
            diceSet.Roll();
            for (int i = 0; i < 6; i++)
            {
                while (diceSet.GetCurrent(i) < 6)
                {
                    diceSet.Reroll(i);
                }
            }
        }
Example #3
0
        public static void Main(string[] argv)
        {
            DiceSet diceSet = new DiceSet();

            do
            {
                diceSet.WriteDice(diceSet);
                diceSet.Reroll();
            } while (diceSet.GetSum(diceSet) != 36);
            diceSet.WriteDice(diceSet);
        }
        public static void Main(string[] argv)
        {
            DiceSet diceSet = new DiceSet();
            int     position;

            diceSet.GetCurrent();
            diceSet.Roll();
            diceSet.GetCurrent();
            diceSet.GetCurrent(5);
            diceSet.Reroll();
            diceSet.GetCurrent();
            diceSet.Reroll(4);
            diceSet.GetCurrent();

            while (true)
            {
                diceSet.printall();
                if (diceSet.finished())
                {
                    break;
                }
                else
                {
                    Console.WriteLine("which position do you want to reroll or enter 9 to reroll all");

                    position = Convert.ToInt32(Console.ReadLine());
                    if (position == 9)
                    {
                        diceSet.Reroll();
                    }
                    else
                    {
                        diceSet.Reroll(position);
                    }
                    //diceSet.Reroll(position);
                }
            }

            Console.WriteLine("game finished");
            Console.ReadKey();
        }
Example #5
0
        public static void Main(string[] argv)
        {
            // You have a `DiceSet` class which has a list for 6 dice
            // You can roll all of them with roll()
            // Check the current rolled numbers with getCurrent()
            // You can reroll with reroll()
            // Your task is to roll the dice until all of the dice are 6

            DiceSet diceSet = new DiceSet();

            for (int i = 0; i < 6; i++)
            {
                while (diceSet.GetCurrent(i) != 6)
                {
                    diceSet.Reroll(i);
                }
            }
            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine($"Dice{i + 1}: {diceSet.GetCurrent(i)}");
            }
        }
Example #6
0
        public static void Main(string[] argv)
        {
            // You have a `DiceSet` class which has a list for 6 dice
            // You can roll all of them with roll()
            // Check the current rolled numbers with getCurrent()
            // You can reroll with reroll()
            // Your task is to roll the dice until all of the dice are 6
            DiceSet.DiceSet diceSet = new DiceSet.DiceSet();

            diceSet.Roll();
            bool completed = false;

            do                                                        //do while - looping(rolling dices) until all of them are 6
            {
                for (int i = 0; i < diceSet.GetCurrent().Length; i++) // for loop - rolling dices seperately
                {
                    if (diceSet.GetCurrent()[i] == 6)
                    {
                        continue;
                    }
                    diceSet.Reroll(i);
                }
                completed = true;
                for (int i = 0; i < diceSet.GetCurrent().Length; i++) // for loop - checks whether all of them are 6
                {
                    if (diceSet.GetCurrent()[i] != 6)
                    {
                        completed = false;
                    }
                }
            } while (!completed);
            for (int i = 0; i < diceSet.GetCurrent().Length; i++)
            {
                Console.WriteLine(diceSet.GetCurrent()[i]);
            }

            Console.ReadLine();
        }