public Fractie Divide(Fractie right) { int r_numarator, r_numitor; r_numitor = numitor * right.numarator; r_numarator = numarator * right.numitor; Console.Write("Performing division of {0}/{1} / {2}/{3} = ", numarator, numitor, right.numarator, right.numitor); return(new Fractie(r_numarator, r_numitor)); }
public Fractie Multiply(Fractie right) { int r_numarator, r_numitor; r_numitor = numitor * right.numitor; r_numarator = numarator * right.numarator; Console.Write("Performing multiplication of {0}/{1} * {2}/{3} = ", numarator, numitor, right.numarator, right.numitor); return(new Fractie(r_numarator, r_numitor)); }
public Fractie Add(Fractie right) { int r_numarator, r_numitor; r_numitor = numitor * right.numitor; r_numarator = numarator * right.numitor + numitor * right.numarator; Console.Write("Performing addition of {0}/{1} + {2}/{3} = ", numarator, numitor, right.numarator, right.numitor); return(new Fractie(r_numarator, r_numitor)); }
public Fractie Subtract(Fractie right) { int r_numarator, r_numitor; r_numitor = numitor * right.numitor; r_numarator = numarator * right.numitor - numitor * right.numarator; Console.Write("Performing subtraction of {0}/{1} - {2}/{3} = ", numarator, numitor, right.numarator, right.numitor); return(new Fractie(r_numarator, r_numitor)); }
static void Main(string[] args) { Fractie f1 = new Fractie(); Fractie f2 = new Fractie(3, 9); Fractie f3 = new Fractie("4 / 8"); Fractie f4; f1.Print(); f2.Print(); f3.Print(); f4 = f2.Add(f3); f4.Print(); f4 = f2.Subtract(f3); f4.Print(); f4 = f2.Multiply(f3); f4.Print(); f4 = f2.Divide(f3); f4.Print(); }