Beispiel #1
0
        public void PolynomialOperatorEqualsTest()
        {
            Polynomial target = new Polynomial(3, new double[] { 3, 2, 1, 0 });
            Polynomial expected = new Polynomial(3, new double[] { 3, 2, 1, 0 });
            Polynomial notExpected = new Polynomial(4, new double[] { 4, 3, 2, 1, 0 });
            Assert.AreEqual(expected.ToString(), target.ToString());
            Assert.IsTrue(target == expected);
            Assert.IsFalse(target != expected);

            Assert.AreNotEqual(notExpected.ToString(), target.ToString());
            Assert.IsFalse(target == notExpected);
            Assert.IsTrue(target != notExpected);

            Assert.IsTrue((Polynomial)(null) == (Polynomial)(null));
            Assert.IsFalse(target == null);
        }
Beispiel #2
0
        public void PolynomialToStringTest()
        {
            Polynomial target = new Polynomial(3);
            string expected = "0x^3\t + 0x^2\t + 0x^1\t + 0";
            string notExpected = "0x^3 + 0x^2 + 0x^1 + 0";
            string actual = "";
            actual = target.ToString();
            Assert.AreEqual(expected, actual);
            Assert.AreNotEqual(notExpected, actual);

            Polynomial target2 = new Polynomial();
            expected = "1";
            notExpected = "\t1";
            actual = target2.ToString();
            Assert.AreEqual(expected, actual);
            Assert.AreNotEqual(notExpected, actual);
        }
Beispiel #3
0
        private static void showPolynom()
        {
            Polynomial P1 = new Polynomial(2, new double[] { 2, 4, 3 });
            Polynomial P2 = new Polynomial(2, new double[] { 2, 4, 3 });

            Polynomial P3 = P1 + P2;
            Polynomial P4 = P1 * P2;
            Polynomial P5 = P4 / P2;

            Console.WriteLine("P1: \n" + P1.ToString());
            Console.WriteLine("P2: \n" + P2.ToString());
            Console.WriteLine("P1 + P2: \n" + P3.ToString());
            Console.WriteLine("P1 * P2: \n" + P4.ToString());
            Console.WriteLine("P1 * P2 / P2: \n" + P5.ToString());
        }