예제 #1
0
        static void Operator(Fraction frac, Fraction frac2, int decision, double num1, double num2)
        {
            //Ausgabe Frage zu Opperator
            Console.Write("Geben sie ihren Rechenoperator ein:(+,-,*,/)\n> ");
            switch (Convert.ToChar(Console.ReadLine()))
            {
            case '+':
                if (decision == 1)
                {
                    //Aufruf der Bruchaddition
                    frac.AddFrac(frac2);
                    frac.ShortFrac();
                    frac.Print();
                }
                else if (decision == 0)
                {
                    //Aufruf der Addition mit Ausgabe
                    Console.WriteLine(BasicArithmeticOperation.Addition(num1, num2));
                }
                break;

            case '-':
                if (decision == 1)
                {
                    //Aufruf der Bruchsubtraktion
                    frac.SubFrac(frac2);
                    frac.ShortFrac();
                    frac.Print();
                }
                else if (decision == 2)
                {
                    Console.WriteLine(BasicArithmeticOperation.Subtraction(num1, num2));
                }
                break;

            case '*':
                if (decision == 1)
                {
                    //Aufruf der Bruchmultiplikation
                    frac.MultiplyFrac(frac2);
                    frac.ShortFrac();
                    frac.Print();
                }
                else if (decision == 2)
                {
                    Console.WriteLine(BasicArithmeticOperation.Multiply(num1, num2));
                }
                break;

            case '/':
                if (decision == 1)
                {
                    //Aufruf der Bruchdivision
                    frac.DivFrac(frac2);
                    frac.ShortFrac();
                    frac.Print();
                }
                else if (decision == 2)
                {
                    Console.WriteLine(BasicArithmeticOperation.Division(num1, num2));
                }
                break;

            default:
                //Wenn falscher Opperator
                Console.WriteLine("Fehlerhafter Opperator!");
                Environment.Exit(1);
                break;
            }
        }