Exemplo n.º 1
0
        // GET: FindOddEven
        public ActionResult Index()
        {
            var v = new EvenOdd();

            v.msg = "";
            return(View(v));
        }
Exemplo n.º 2
0
 public void tes_even_odd()
 {
     Assert.True(EvenOdd.isOdd(5));
     Assert.False(EvenOdd.isOdd(6));
     Assert.True(EvenOdd.isEven(6));
     Assert.False(EvenOdd.isEven(5));
 }
Exemplo n.º 3
0
 public void MyTest()
 {
     Assert.AreEqual("Even", EvenOdd.EvenOrOdd(2));
     Assert.AreEqual("Odd", EvenOdd.EvenOrOdd(1));
     Assert.AreEqual("Even", EvenOdd.EvenOrOdd(0));
     Assert.AreEqual("Odd", EvenOdd.EvenOrOdd(7));
     Assert.AreEqual("Odd", EvenOdd.EvenOrOdd(-1));
 }
Exemplo n.º 4
0
        public void TestZero()
        {
            var  number   = 0;
            bool?expected = null;

            var actual = EvenOdd.Check(number);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 5
0
        public static int[] GetFactor(EvenOdd evenOdd)
        {
            if (evenOdd == EvenOdd.None)
            {
                return(EmptyNumbers);
            }

            return(InFieldNumbers.Where(num => num.GetEvenOdd() == evenOdd).ToArray());
        }
Exemplo n.º 6
0
    static void Main()
    {
        while (1 < 2)
        {
            Console.Write("Enter an integer number: ");

            // Read an integer from the console
            int num = int.Parse(Console.ReadLine());

            // Get the value "ODD" or "EVEN" from enumeration
            EvenOdd evenOdd = (EvenOdd)(Math.Abs(num % 2));

            Console.WriteLine("The number {0} is {1}.", num, evenOdd);
        }
    }
Exemplo n.º 7
0
        public ActionResult Index(String a)
        {
            int num = Convert.ToInt16(a);
            var v   = new EvenOdd();

            if ((num % 2) == 0)
            {
                v.msg = "Number is Even";
            }
            else
            {
                v.msg = "Number is Odd";
            }

            return(View(v));
        }
Exemplo n.º 8
0
        public static Crossings FindCrossings(ArrayList curves,
                double xlo, double ylo,
                double xhi, double yhi)
        {
            Crossings cross = new EvenOdd(xlo, ylo, xhi, yhi);
            IEnumerator enumerator = curves.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Curve c = (Curve)enumerator.Current;
                if (c.AccumulateCrossings(cross))
                {
                    return null;
                }
            }

            return cross;
        }
Exemplo n.º 9
0
        public static Crossings FindCrossings(ArrayList curves,
                                              double xlo, double ylo,
                                              double xhi, double yhi)
        {
            Crossings   cross      = new EvenOdd(xlo, ylo, xhi, yhi);
            IEnumerator enumerator = curves.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Curve c = (Curve)enumerator.Current;
                if (c.AccumulateCrossings(cross))
                {
                    return(null);
                }
            }

            return(cross);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            int[] allNumbers = { 3, 6, 2, 5, 24, 63, 26, 32, 62, 7, 0, 6, 2 };

            EvenOdd e = new EvenOdd();

            e.GetEven(allNumbers);
            e.GetOdd(allNumbers);

            ProcessData pr = new ProcessData();

            pr.GetWorkersGroupByCompany();
            pr.GetWorkersolderFiftyGroupByCompany();
            pr.GetWorkersWithMaxSalaryGroupByCompany();
            Fibonacci fib = new Fibonacci();

            fib.Count(6);

            Factorial fact = new Factorial();

            fact.Count(7);

            Console.ReadKey();
        }
Exemplo n.º 11
0
 public void Test5()
 {
     Assert.True(EvenOdd.isOdd(5));
     Assert.True(EvenOdd.isEven(6));
 }
Exemplo n.º 12
0
        public static Crossings FindCrossings(PathIterator pi,
                                              double xlo, double ylo,
                                              double xhi, double yhi)
        {
            Crossings cross;

            if (pi.GetWindingRule() == PathIterator.WIND_EVEN_ODD)
            {
                cross = new EvenOdd(xlo, ylo, xhi, yhi);
            }
            else
            {
                cross = new NonZero(xlo, ylo, xhi, yhi);
            }
            // coords array is big enough for holding:
            //     coordinates returned from currentSegment (6)
            //     OR
            //         two subdivided quadratic curves (2+4+4=10)
            //         AND
            //             0-1 horizontal splitting parameters
            //             OR
            //             2 parametric equation derivative coefficients
            //     OR
            //         three subdivided cubic curves (2+6+6+6=20)
            //         AND
            //             0-2 horizontal splitting parameters
            //             OR
            //             3 parametric equation derivative coefficients
            var    coords = new int[23];
            double movx   = 0;
            double movy   = 0;
            double curx   = 0;
            double cury   = 0;

            while (!pi.IsDone())
            {
                int    type = pi.CurrentSegment(coords);
                double newx;
                double newy;
                switch (type)
                {
                case PathIterator.SEG_MOVETO:
                    if (movy != cury &&
                        cross.AccumulateLine(curx, cury, movx, movy))
                    {
                        return(null);
                    }
                    movx = curx = coords[0];
                    movy = cury = coords[1];
                    break;

                case PathIterator.SEG_LINETO:
                    newx = coords[0];
                    newy = coords[1];
                    if (cross.AccumulateLine(curx, cury, newx, newy))
                    {
                        return(null);
                    }
                    curx = newx;
                    cury = newy;
                    break;

                case PathIterator.SEG_QUADTO:
                {
                    newx = coords[2];
                    newy = coords[3];
                    var dblCoords = new double[coords.Length];
                    for (int i = 0; i < coords.Length; i++)
                    {
                        dblCoords[i] = coords[i];
                    }
                    if (cross.AccumulateQuad(curx, cury, dblCoords))
                    {
                        return(null);
                    }
                    curx = newx;
                    cury = newy;
                }
                break;

                case PathIterator.SEG_CUBICTO:
                {
                    newx = coords[4];
                    newy = coords[5];
                    var dblCoords = new double[coords.Length];
                    for (int i = 0; i < coords.Length; i++)
                    {
                        dblCoords[i] = coords[i];
                    }
                    if (cross.AccumulateCubic(curx, cury, dblCoords))
                    {
                        return(null);
                    }
                    curx = newx;
                    cury = newy;
                    break;
                }

                case PathIterator.SEG_CLOSE:
                    if (movy != cury &&
                        cross.AccumulateLine(curx, cury, movx, movy))
                    {
                        return(null);
                    }
                    curx = movx;
                    cury = movy;
                    break;
                }
                pi.Next();
            }
            if (movy != cury)
            {
                if (cross.AccumulateLine(curx, cury, movx, movy))
                {
                    return(null);
                }
            }

            return(cross);
        }
Exemplo n.º 13
0
        public void PrimeTest(int input, bool expected)
        {
            bool result = EvenOdd.isPrime(input);

            Assert.Equal(expected, result);
        }
Exemplo n.º 14
0
        public void EvenOddTest(int input, string expected)
        {
            string result = EvenOdd.GetWord(input);

            Assert.Equal(expected, result);
        }
Exemplo n.º 15
0
        public static Crossings FindCrossings(PathIterator pi,
                double xlo, double ylo,
                double xhi, double yhi)
        {
            Crossings cross;
            if (pi.GetWindingRule() == PathIterator.WIND_EVEN_ODD)
            {
                cross = new EvenOdd(xlo, ylo, xhi, yhi);
            }
            else
            {
                cross = new NonZero(xlo, ylo, xhi, yhi);
            }
            // coords array is big enough for holding:
            //     coordinates returned from currentSegment (6)
            //     OR
            //         two subdivided quadratic curves (2+4+4=10)
            //         AND
            //             0-1 horizontal splitting parameters
            //             OR
            //             2 parametric equation derivative coefficients
            //     OR
            //         three subdivided cubic curves (2+6+6+6=20)
            //         AND
            //             0-2 horizontal splitting parameters
            //             OR
            //             3 parametric equation derivative coefficients
            var coords = new int[23];
            double movx = 0;
            double movy = 0;
            double curx = 0;
            double cury = 0;
            while (!pi.IsDone())
            {
                int type = pi.CurrentSegment(coords);
                double newx;
                double newy;
                switch (type)
                {
                    case PathIterator.SEG_MOVETO:
                        if (movy != cury &&
                                cross.AccumulateLine(curx, cury, movx, movy))
                        {
                            return null;
                        }
                        movx = curx = coords[0];
                        movy = cury = coords[1];
                        break;
                    case PathIterator.SEG_LINETO:
                        newx = coords[0];
                        newy = coords[1];
                        if (cross.AccumulateLine(curx, cury, newx, newy))
                        {
                            return null;
                        }
                        curx = newx;
                        cury = newy;
                        break;
                    case PathIterator.SEG_QUADTO:
                        {
                            newx = coords[2];
                            newy = coords[3];
                            var dblCoords = new double[coords.Length];
                            for (int i = 0; i < coords.Length; i++)
                            {
                                dblCoords[i] = coords[i];
                            }
                            if (cross.AccumulateQuad(curx, cury, dblCoords))
                            {
                                return null;
                            }
                            curx = newx;
                            cury = newy;
                        }
                        break;
                    case PathIterator.SEG_CUBICTO:
                        {
                            newx = coords[4];
                            newy = coords[5];
                            var dblCoords = new double[coords.Length];
                            for (int i = 0; i < coords.Length; i++)
                            {
                                dblCoords[i] = coords[i];
                            }
                            if (cross.AccumulateCubic(curx, cury, dblCoords))
                            {
                                return null;
                            }
                            curx = newx;
                            cury = newy;
                            break;
                        }
                    case PathIterator.SEG_CLOSE:
                        if (movy != cury &&
                                cross.AccumulateLine(curx, cury, movx, movy))
                        {
                            return null;
                        }
                        curx = movx;
                        cury = movy;
                        break;
                }
                pi.Next();
            }
            if (movy != cury)
            {
                if (cross.AccumulateLine(curx, cury, movx, movy))
                {
                    return null;
                }
            }

            return cross;
        }
Exemplo n.º 16
0
 public void EvenOdd_Test()
 {
     Assert.True(EvenOdd.IsEven(8));
     Assert.False(EvenOdd.IsOdd(4));
 }
Exemplo n.º 17
0
 public void Test_EvenOdd(int input, string expectedResult)
 {
     Assert.AreEqual(expectedResult, EvenOdd.EvenOrOdd(input));
 }
Exemplo n.º 18
0
        public void TestEven(int number)
        {
            var actual = EvenOdd.Check(number);

            Assert.True(actual);
        }