コード例 #1
0
ファイル: Program.cs プロジェクト: phealeyh/31927-Csharp-labs
        static void Main(string[] args)
        {
            Rational a, b;

            a = new Rational(2, -4);
            b = new Rational(4, 2);

            Console.WriteLine("Printing a");
            Console.WriteLine("Rational number is " + a.ToString());
            Console.WriteLine();

            Console.WriteLine("Printing b");
            Console.WriteLine("Rational number is " + b.ToString());
            Console.WriteLine();

            Console.WriteLine("Adding a & b");
            Console.WriteLine("Rational number is " + (a + b).ToString());
            Console.WriteLine();

            Console.WriteLine("Subtracting b from a");
            Console.WriteLine("Rational number is " + (a - b).ToString());
            Console.WriteLine();

            Console.WriteLine("Multiplying a & b");
            Console.WriteLine("Rational number is " + (a * b).ToString());
            Console.WriteLine();

            Console.WriteLine("Dividing a by b");
            Console.WriteLine("Rational number is " + (a / b).ToString());

            Console.ReadLine();
        }
コード例 #2
0
        public void Test2()
        {
            Rational r = new Rational(0, 0);

            Assert.NotNull(r);
            Assert.IsTrue(r.Denominator > 0);
        }