예제 #1
0
        public Fractie Multiply(Fractie right)
        {
            int r_numarator, r_numitor;

            r_numarator = numarator * right.numarator;
            r_numitor   = numitor * right.numitor;
            return(new Fractie(r_numarator, r_numitor));
        }
예제 #2
0
        public Fractie Add(Fractie right)
        {
            int r_numarator, r_numitor;

            r_numitor   = numitor * right.numitor;
            r_numarator = numarator * right.numitor + numitor * right.numarator;
            return(new Fractie(r_numarator, r_numitor));
        }
예제 #3
0
        public Fractie Subtract(Fractie right)
        {
            int r_numarator, r_numitor;

            r_numitor   = numitor * right.numitor;
            r_numarator = numarator * right.numitor - numitor * right.numarator;
            return(new Fractie(r_numarator, r_numitor));
        }
예제 #4
0
        static void Main(string[] args)
        {
            Fractie f1 = new Fractie();
            Fractie f2 = new Fractie(3, 9);

            f1.Print();
            f2.Print();
            Fractie f3 = new Fractie("2 / 4");

            f3.Print();
            Fractie f4;

            f4 = f2.Add(f3);
            f4.Print();

            f4 = f2.Multiply(f3);
            f4.Print();

            f4 = f2.Subtract(f3);
            f4.Print();

            f4 = f2.Divide(f3);
            f4.Print();
        }