Пример #1
0
        public void TestAddNumericDie()
        {
            var testPool = new DicePool.DicePool("test pool");
            var dice     = testPool.AddDie(6, "test die", 2);

            Assert.AreEqual(2, dice.Count);
        }
Пример #2
0
        public void TestRollPool()
        {
            var testPool = new DicePool.DicePool("test pool");

            testPool.AddDie(6, "test die", 2);

            var testResult = testPool.RollPool();

            Assert.IsInstanceOf <RollResult>(testResult);
        }
Пример #3
0
        static void Main(string[] args)
        {
            string command;

            string[] words;
            DicePool dPool = new DicePool();
            int      result;

            do
            {
                Console.WriteLine("Please enter a command: ");
                command = Console.ReadLine();
                command = command.ToLower();
                command = command.Trim();
                while (command.Contains("  "))
                {
                    command.Replace("  ", " ");
                }
                words = command.Split(' ');
                if (words[0] == "add")
                {
                    dPool.Add(int.Parse(words[1]));
                    Console.WriteLine(words[1] + " sided dice is added in the system.");
                }
                else if (words[0] == "roll")
                {
                    result = dPool.Roll(int.Parse(words[1]));
                    if (result == -1)
                    {
                        Console.WriteLine(words[1] + " sided dice is not available");
                    }
                    else
                    {
                        Console.WriteLine("Dice No: " + words[1] + " Roll result: " + result);
                    }
                }

                else if (words[0] == "remove")
                {
                    if (dPool.Remove(int.Parse(words[1])) == true)
                    {
                        Console.WriteLine("Dice No: " + words[1] + " is succefully removed from the system");
                    }
                    else
                    {
                        Console.WriteLine("Dice No: " + words[1] + " is not found");
                    }
                }

                else if (words[0] == "rollall")
                {
                    result = dPool.RollAll();
                    Console.WriteLine("Summation of all rools: " + result);
                }
                else
                {
                    Console.WriteLine("Please enter in correct format! ");
                }
            } while (command != "exit");



            //Dice obj6 = new Dice(6);
            //for (int i=0; i<10; i++)
            //{
            //    Console.WriteLine("Roll " + (i + 1) + " Result: " + obj6.Roll());
            //}
            //Console.ReadLine();
        }