void Start() { personToggle.isOn = true; sureBtn.onClick.AddListener(OnClickSureBtn); PersonalStrategy personalStrategy = new PersonalStrategy(8000); CaculateStrategy.Caculate(personalStrategy); }
void OnClickSureBtn() { if (input.text == null || input.text == "") { showTxt.text = "您没有输入工资,请重新输入!"; return; } double money = double.Parse(input.text); if (money <= 6000) { if (personToggle.isOn) { showTxt.text = "月薪" + money + ", 穷逼,不用缴税"; } else { showTxt.text = "月入" + money + ", 开JB公司"; } } else { if (personToggle.isOn) { PersonalStrategy personalStrategy = new PersonalStrategy(money); double tempMon = CaculateStrategy.Caculate(personalStrategy); showTxt.text = "月薪" + money + ", 个人需要缴税为:" + tempMon; } else { CompanyStrategy companyStrategy = new CompanyStrategy(money); double tem = CaculateStrategy.Caculate(companyStrategy); showTxt.text = "月入" + money + ", 公司需要缴税为:" + tem; } } }