using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ch6_2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Rational ra1 = new Rational();
        Rational ra2 = new Rational();
        Rational ra3 = new Rational();

        private void Add_Click(object sender, EventArgs e)
        {
            ra1.x = Convert.ToInt16(textBox1.Text);
            ra1.y = Convert.ToInt16(textBox2.Text);
            ra2.x = Convert.ToInt16(textBox3.Text);
            ra2.y = Convert.ToInt16(textBox4.Text);
            ra3 = ra3.add(ra1, ra2);
            label5.Text = "Add of two rational : ";
            label5 .Text += (ra3.x).ToString () + "/" + (ra3.y).ToString ();
        }

        private void Mul_Click(object sender, EventArgs e)
        {
            ra1.x = Convert.ToInt16(textBox1.Text);
            ra1.y = Convert.ToInt16(textBox2.Text);
            ra2.x = Convert.ToInt16(textBox3.Text);
            ra2.y = Convert.ToInt16(textBox4.Text);
            ra3.mul(ra1, ra2, ra3);
            label5.Text = "Multiply of two rational : ";
            label5.Text += (ra3.x).ToString() + "/" + (ra3.y).ToString();


        }

        private void Sub_Click(object sender, EventArgs e)
        {
            ra1.x = Convert.ToInt16(textBox1.Text);
            ra1.y = Convert.ToInt16(textBox2.Text);
            ra2.x = Convert.ToInt16(textBox3.Text);
            ra2.y = Convert.ToInt16(textBox4.Text);
            ra3.sub(ra1, ra2, ra3);
            label5.Text = "Subtract of two rational : ";
            label5.Text += (ra3.x).ToString() + "/" + (ra3.y).ToString();

        }

        private void Div_Click(object sender, EventArgs e)
        {
            ra1.x = Convert.ToInt16(textBox1.Text);
            ra1.y = Convert.ToInt16(textBox2.Text);
            ra2.x = Convert.ToInt16(textBox3.Text);
            ra2.y = Convert.ToInt16(textBox4.Text);
            ra3.div(ra1, ra2, ra3);
            label5.Text = "Add of two rational : ";
            label5.Text += (ra3.x).ToString() + "/" + (ra3.y).ToString();
        }
    }
}
