private void button1_Click(object sender, EventArgs e) { Cal cal = new Cal(); cal.Add(10, 20); MessageBox.Show(cal.Result.ToString()); }
static void Main(string[] args) { ICalc c = new Cal(); int s = c.Add(2, 3); Console.WriteLine($"2+3={s}"); Console.ReadKey(); }
public void TestAdd() { ICalc c = new Cal(); int expected = 5; int actual = c.Add(2, 3); Assert.AreEqual(expected, actual); }
public void Calc_檢查加法運算_負數加負數() { // arrange ICalc c = new Cal(); // 期望值 int expected = -5; //-2-3=-5 // act // 實際結果 int actual = c.Add(-2, -3); // assert // 比對(請注意類型) Assert.AreEqual(expected, actual); }
public void Calc_檢查加法運算() { // arrange ICalc c = new Cal(); // 期望值 int expected = 5; //2+3=5 // act // 實際結果 int actual = c.Add(2, 3); // assert // 比對(請注意類型) Assert.AreEqual(expected, actual); }
static void Main(string[] args) { Console.Write("Enter First Number: "); int num1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter First Number: "); int num2 = Convert.ToInt32(Console.ReadLine()); Console.Write("Which Opertation You Want To Perform: "); string op = Console.ReadLine(); switch (op) { case "+": Console.WriteLine(Cal.Add(num1, num2)); break; case "-": Console.WriteLine(Cal.Sub(num1, num2)); break; case "*": Console.WriteLine(Cal.Mul(num1, num2)); break; case "/": Console.WriteLine(Cal.Div(num1, num2)); break; case "%": Console.WriteLine(Cal.Mod(num1, num2)); break; default: Console.WriteLine("Invalid Input"); break; } Console.ReadLine(); }