예제 #1
0
 public void EvenOrOdd_GetEvenOrOdd_BasicTest()
 {
     Assert.AreEqual("Even", EvenOrOdd.GetEvenOrOdd(2));
     Assert.AreEqual("Odd", EvenOrOdd.GetEvenOrOdd(1));
     Assert.AreEqual("Even", EvenOrOdd.GetEvenOrOdd(0));
     Assert.AreEqual("Odd", EvenOrOdd.GetEvenOrOdd(7));
 }
예제 #2
0
 public void EvenOrOdd_GetEvenOrOdd_AdditionalTest()
 {
     Assert.AreEqual("Even", EvenOrOdd.GetEvenOrOdd(1545452));
     Assert.AreEqual("Odd", EvenOrOdd.GetEvenOrOdd(17));
     Assert.AreEqual("Even", EvenOrOdd.GetEvenOrOdd(78));
     Assert.AreEqual("Odd", EvenOrOdd.GetEvenOrOdd(74156741));
 }
예제 #3
0
        static void Main(string[] args)
        {
            //int num1, num2, temp;

            //Console.WriteLine("\nEnter two numbers: ");
            //num1 = int.Parse(Console.ReadLine());
            //num2 = int.Parse(Console.ReadLine());

            //temp = num1;
            //num1 = num2;
            //num2 = temp;

            //Console.Write("After swapping: " + num1 + ", " + num2);
            //Console.Write("Enter a string in upper-case: ");
            //string strr = Console.ReadLine();

            //Console.Write("Here is the upper-case v of it: " + ToLower(strr));

            EvenOrOdd e = new EvenOrOdd();

            Console.Write("Enter a number: ");
            e.EvenOdd(int.Parse(Console.ReadLine()));

            Console.ReadKey();
        }
예제 #4
0
        public void GetIsEvenOrOdd_ShouldReturnStringWithTheResult(IEnumerable <int> numbers, string expectedResult)
        {
            var testee = new EvenOrOdd();

            var result = testee.GetIsEvenOrOdd(numbers);

            result.Should().Be(expectedResult);
        }
예제 #5
0
        public void IsEvenOrOddsTest_Ifnumberis1_ThenThisisOdd()
        {
            var    number   = 1;
            var    EvenOdd  = new EvenOrOdd();
            string expected = "Odd";
            var    actual   = EvenOdd.IsEvenOrOdds(number);

            Assert.AreSame(expected, actual);
        }
예제 #6
0
        public void EvenOrOdd_GetEvenOrOdd_OneReturnsOdd()
        {
            // arrange

            // act

            // assert
            Assert.AreEqual("Odd", EvenOrOdd.GetEvenOrOdd(1));
        }
예제 #7
0
        public void EvenOrOdd_GetEvenOrOdd_TwoReturnsEven()
        {
            // arrange

            // act

            // assert
            Assert.AreEqual("Even", EvenOrOdd.GetEvenOrOdd(2));
        }
예제 #8
0
        void translate_color_of_tiles_cubes(Vector3 factor, EvenOrOdd even_or_odd)
        {
            var color_translation = color_translate_speed * Time.deltaTime;

            color_translation.x *= factor.x;
            color_translation.y *= factor.y;
            color_translation.z *= factor.z;

            var max_color = Vector3.one;

            max_color.x *= color_max.x;
            max_color.y *= color_max.y;
            max_color.z *= color_max.z;

            var min_color = Vector3.one;

            min_color.x *= color_min.x;
            min_color.y *= color_min.y;
            min_color.z *= color_min.z;

            bool current_is_even = false;

            foreach (var tile in puzzle_tiles)
            {
                current_is_even = !current_is_even;

                switch (even_or_odd)
                {
                case EvenOrOdd.Even:
                    if (!current_is_even)
                    {
                        continue;
                    }
                    break;

                case EvenOrOdd.Odd:
                    if (current_is_even)
                    {
                        continue;
                    }
                    break;
                }

                var renderer      = tile.cube.GetComponent <Renderer>();
                var material      = renderer.materials[0];
                var initial_color = material.color;


                var new_color = new Vector3(initial_color.r, initial_color.g, initial_color.b) + color_translation;
                new_color = Vector3.Min(new_color, max_color);
                new_color = Vector3.Max(new_color, min_color);

                material.color = new Color(new_color.x, new_color.y, new_color.z);
            }
        }
        public void EvenOrOdd(int number, string expected)
        {
            // Arrange
            EvenOrOdd EvenOrOdd = new EvenOrOdd();

            // Act
            string actual = EvenOrOdd.EvenOrOddTests(number);

            // Assert
            Assert.Equal(expected, actual);
        }
예제 #10
0
        public void Should_Return_Even_When_Sum_Of_Odd_Inputs_Is_Even(int[] input, string expected)
        {
            // Arrange
            EvenOrOdd evenOrOddKata = new EvenOrOdd();

            // Act
            string output = evenOrOddKata.oddOrEven(input);

            // Assert
            Assert.AreEqual(expected, output);
        }
예제 #11
0
        static List <T> Filter <T>(EvenOrOdd <T> filter, List <T> numbers)
        {
            List <T> returnList = new List <T>();

            foreach (T item in numbers)
            {
                if (filter(item))
                {
                    returnList.Add(item);
                }
            }

            return(returnList);
        }
예제 #12
0
        public void EvenOrOdd_GetEvenOrOdd_Random()
        {
            const int Tests  = 100;
            var       random = new Random();

            for (int i = 0; i < Tests; ++i)
            {
                var randomNumber = random.Next();

                var expected = randomNumber % 2 == 0 ? "Even" : "Odd";

                // assert
                Assert.AreEqual(expected, EvenOrOdd.GetEvenOrOdd(randomNumber));
            }
        }
예제 #13
0
        static void Main()
        {
            List <int> Numbers = new List <int> {
                0, 6, 5, 3, 2, 4, 1, 7, 8, 9
            };
            FilterClass     filter          = new FilterClass();
            EvenOrOdd <int> filterEven      = filter.IsEven;
            EvenOrOdd <int> filterOdd       = filter.IsOdd;
            EvenOrOdd <int> greaterThanFive = filter.IsGreaterthanFive;

            EvenOrOdd <int> anonymous = delegate(int num)
            {
                return(num > 2 && num < 5 ? true : false);
            };

            Numbers = Filter(anonymous, Numbers);

            List <Product> products = new List <Product>
            {
                new Product {
                    Name = "dell xps", Id = 1, Price = 40000, Description = "new laptop from dell"
                },
                new Product {
                    Name = "MotoG3", Id = 2, Price = 5000, Description = "New mobile from Motorola"
                },
                new Product {
                    Name = "Hpnote", Id = 3, Price = 45000, Description = "Hp laptop"
                }
            };
            EvenOrOdd <Product> sortProductPrice = (product) => product.Price >= 40000;

            EvenOrOdd <Product> sortPrductName = (product) => product.Name.Contains('M');

            SortProduct sorter = new SortProduct();

            //products.Sort(sorter);

            Comparison <Product> compareLogic = (x, y) => x.Name.CompareTo(y.Name);

            products.Sort(compareLogic);

            PrintList <Product>(products);

            products = Filter <Product>(sortPrductName, products);

            PrintList <Product>(products);
        }
예제 #14
0
 public void Setup()
 {
     _evenOrOdd = new EvenOrOdd();
 }
예제 #15
0
 public void Test_OddOrEven()
 {
     Assert.True(EvenOrOdd.isOdd(21));
     Assert.True(EvenOrOdd.isEven(20));
 }
예제 #16
0
        public void Play()
        {
            bool   play;
            string playAgain;

            while (play = true && Player.money > 0)
            {
                Console.Clear();
                WriteText.WriteLine("Place Your Bets!", ConsoleColor.Red);
                WriteText.WriteLine($"Choose a number cooresponding to the bet you'd like to place\n" +

                                    $"1: bet on a number(1/36 odds)\t 2: Even or Odds(1/2 odds)\t 3: Red or Black(1/2 odds)\n" +

                                    $"4: Lows or Highs(1/2 odds)\t 5: Dozens(1/3 odds)\t 6: Column bet(1/3 odds)\n" +

                                    $"7: Street(1/12 odds)\t 8: six-line(1/6 odds)\t 9: Split(1/18 odds)\n" +

                                    $"10: Corner bet(1/9 odds)", ConsoleColor.Green);
                int chosenBet = Int32.Parse(Console.ReadLine());

                //switch (chosenBet)
                //{
                //    case 1: chosenBet > 10;
                //    throw new IndexOutOfRangeException("You chose a number that dose not match any of the bets.");
                //    break;
                //}
                if (chosenBet > 10)
                {
                    throw new IndexOutOfRangeException("You chose a number that dose not match any of the bets.");
                }
                if (chosenBet == 1)
                {
                    Number number = new Number();
                    number.NumbersBet(Spin());
                }

                if (chosenBet == 2)
                {
                    EvenOrOdd evenorodd = new EvenOrOdd();
                    evenorodd.EvenOrOddBet(Spin());
                }
                if (chosenBet == 3)
                {
                    RedOrBlack redorblack = new RedOrBlack();
                    redorblack.RedOrBlackBet(Spin());
                }
                if (chosenBet == 4)
                {
                    LowsHighs loworhigh = new LowsHighs();
                    loworhigh.LowOrHighBet(Spin());
                }
                if (chosenBet == 5)
                {
                    Dozens dozens = new Dozens();
                    dozens.DozensBet(Spin());
                }
                if (chosenBet == 6)
                {
                    Columns columns = new Columns();
                    columns.ColumnBet(Spin());
                }
                if (chosenBet == 7)
                {
                    Street street = new Street();
                    street.StreetBet(Spin());
                }
                if (chosenBet == 8)
                {
                    SixLine sixLine = new SixLine();
                    sixLine.SixLineBet(Spin());
                }
                if (chosenBet == 9)
                {
                    Split split = new Split();
                    split.SplitBet(Spin());
                }
                if (chosenBet == 10)
                {
                    Corner corner = new Corner();
                    corner.CornerBet(Spin());
                }
                if (Player.money == 0)
                {
                    play = false;
                    WriteText.WriteLine("You lost all you own GET OUT!", ConsoleColor.Red);
                    Console.ReadKey();
                }
                if (Player.money > 0)
                {
                    WriteText.WriteLine("Play again? (yes/no): ", ConsoleColor.Red);
                    playAgain = Console.ReadLine();
                    playAgain.ToLower();
                    if (playAgain == "yes")
                    {
                        play = true;
                        Random random = new Random();
                        int    phrase = random.Next(1, 3);
                        if (phrase == 1)
                        {
                            WriteText.WriteLine("Its always possible to have Better luck this time.", ConsoleColor.Red);
                        }
                        if (phrase == 2)
                        {
                            WriteText.WriteLine("Play Again!? Why?", ConsoleColor.Red);
                        }
                        if (phrase == 3)
                        {
                            WriteText.WriteLine("Luck is on your side.", ConsoleColor.Red);
                            Console.ReadKey();
                        }
                    }
                }
            }
        }
예제 #17
0
 public void ShouldReturnEvenWhenPassedValueIsEvenAndOddWithValuePassedIsOdd(int value, string expected)
 {
     Assert.Equal(expected, EvenOrOdd.EvenOdd(value));
 }