Example #1
0
 public static fraction operator -(fraction x, fraction y)
 {
     fraction z = new fraction();
     z.Num = x.Num * y.Den - y.Num * x.Den;
     z.Den = x.Den * y.Den;
     z.Reduce();
     return z;
 }
Example #2
0
File: Form1.cs Project: jbenua/JSM
 private void button1_Click(object sender, EventArgs e)
 {
     int a, b;
     if (textBoxNum.Text == "")
     {
         fraction f = new fraction();
         frac.Text = f.Num + "/" + f.Den;
     }
     else
     {
         a = Convert.ToInt32(textBoxNum.Text);
         if (textBoxDen.Text == "")
         {
             fraction f = new fraction(a);
             frac.Text = f.Num + "/" + f.Den;
         }
         else
         {
             b = Convert.ToInt32(textBoxDen.Text);
             fraction f = new fraction(a, b);
             frac.Text = f.Num + "/" + f.Den;
         }
     }
 }
Example #3
0
 public fraction(fraction x)
 {
     n = x.n;
     d = x.d;
 }