Professional Documents
Culture Documents
Please design the following form. Be sure to use size 12 fonts for all objects.
Modify the code window so it looks like the following. Please note the ADTs are defined at the end of the namespace. I have placed each form on a different page for simplicity.
1|Page
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void Form1_Load(object sender, EventArgs e) { } private void btnCalculate_Click(object sender, EventArgs e) { Calculator c = new Calculator(); c.storeX(int.Parse(txtNum1.Text)); c.storeY(int.Parse(txtNum2.Text)); c.storeSymbol(lblSymb.Text); txtResult.Text = c.process().ToString(); } private void radAdd_CheckedChanged(object sender, EventArgs e) { lblSymb.Text = radAdd.Text ; } private void radSub_CheckedChanged(object sender, EventArgs e) { lblSymb.Text = radSub.Text; } private void radMul_CheckedChanged(object sender, EventArgs e) { lblSymb.Text = radMul.Text; } private void radDiv_CheckedChanged(object sender, EventArgs e) { lblSymb.Text = radDiv.Text; }
2|Page
public void storeX(int a) { x = a; } public void storeY(int b) { y = b; } public int getX() { return x; } public int getY() { return y; } }
3|Page
class Calculator : Number { private string symb; public void storeSymbol(string c) { symb = c; } public string process() { if (symb == "+") { res = getX() + getY(); } else if (symb == "-") { res = getX() - getY(); } else if (symb == "*") { res = getX() * getY(); } else if (symb == "/") { try { res = (float) getX()/ getY(); } catch (Exception e) { return e.Message; } } return res.ToString(); }
} }
4|Page