Ejemplo n.º 1
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();

            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);
            }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            RandomValue = new Random();
            DiceSet myDice = new DiceSet();

            myDice.WriteOutDices(myDice.DoSixes());
            Console.ReadLine();
        }
Ejemplo n.º 3
0
 public void WriteDice(DiceSet diceSet)
 {
     for (int i = 0; i < 6; i++)
     {
         Console.Write(diceSet.GetCurrent(0 + i));
     }
     Console.WriteLine();
 }
Ejemplo n.º 4
0
 public static void Main(string[] args)
 {
     RandomValue = new Random();
     DiceSet.Roll();
     DiceSet.WriteOutDices(DiceSet.GetCurrent());
     DiceSet.WriteOutDices(DiceSet.DoSixes());
     Console.ReadLine();
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public int GetSum(DiceSet diceSet)
        {
            int sum = 0;

            for (int i = 0; i <= dice.Length - 1; i++)
            {
                sum += diceSet.GetCurrent(i);
            }

            return(sum);
        }
Ejemplo n.º 7
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);
                }
            }
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
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)}");
            }
        }
Ejemplo n.º 10
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();
        }
Ejemplo n.º 11
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();

            diceSet.Roll();

            foreach (var item in diceSet)
            {
                Console.WriteLine(diceSet.GetCurrent());
            }

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