封装,策略模式,Asp换脸
1.简单封装 1》计算类 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 计算 { class operater1 { private int x; private int y; private string opers; private int answer; public int X { set { x = value; } } public int Y { set { y = value; } } public string Opers { set { opers = value; } } public int Answer { get { return answer; } } public void operation() { switch (opers) { case "+": answer = x + y; break; case "-": if (x > y) { answer = x - y; } else { throw new Exception("被减数不能小于减数!"); } break; case "*": answer = x * y; break; case "/": if (y == 0) { throw