# how can i design simple calculation software through object oriented programming in c#? [on hold]

I’m a novice C# programmer and unfortunately I can’t design classes for simple software, for example, a calculator application with C#. A lot of people said to me: Just write many projects and then you will be a good programmer!!!,in fact,i wanna know that how do you think?

this is my calculation class.

````         public class Calculation     {         public Stack<int> StackNumber = new Stack<int>();         public Stack<string> StackString = new Stack<string>();         public int[] saveNumbers = new int[2];      private void Add(int number1, int number2)     {         StackNumber.Push(number1 + number2);     }      private void Subtract(int number1, int number2)     {         StackNumber.Push(number1 - number2);     }      private void Multipy(int number1, int number2)     {         StackNumber.Push(number1 * number2);     }      private void Divide(int number1, int number2)     {         StackNumber.Push(number1 / number2);     }      public void SeprateNumberFromOperator(string text)     {         int number;          int count = text.Length;         while (count > 0)         {             char item = Convert.ToChar(text.Substring(count - 1, 1));              if (int.TryParse(item.ToString(), out number) && item != ' ')             {                 StackNumber.Push((int)char.GetNumericValue(item));             }             else if (!int.TryParse(item.ToString(), out number) && item != ' ')             {                 StackString.Push(item.ToString());             }             count--;         }          DetectOperator();     }      private void DetectOperator()     {         int count = 0;         while (StackString.Count > 0)         {             if (count == 2)             {                 switch (StackString.Pop())                 {                     case "+":                         Add(saveNumbers[0], saveNumbers[1]);                         break;                      case "-":                         Subtract(saveNumbers[0], saveNumbers[1]);                         break;                      case "*":                         Multipy(saveNumbers[0], saveNumbers[1]);                         break;                      case "/":                         Divide(saveNumbers[0], saveNumbers[1]);                         break;                 }             }             if (count == 2)             {                 count = 0;             }             saveNumbers[count] = StackNumber.Pop();             count++;         }         if (StackString.Count == 0)         {             MessageBox.Show(saveNumbers[0].ToString());         }     } }         private void btnCall_Click(object sender, EventArgs e)         {             Calculation calc = new Calculation();              int number;             Button btn = sender as Button;         if (btn.Text == "C")         {             txtNumber.Clear();             txtNumber.Focus();         }         else if (!int.TryParse(btn.Text, out number))         {             if (btn.Text == "=")             {                 calc.SeprateNumberFromOperator(txtNumber.Text);              }             else                  txtNumber.Text += btn.Text;         }         else         {             txtNumber.Text += btn.Text;         }     } `
```

Replay

Category: c# Time: 2016-07-29 Views: 0