private void button1_Click(object sender, EventArgs e) { String target = this.TargetUnitBox.Text; int inputNum = Int32.Parse(this.InputUnit.Text); Double output = mileHandler.Handle(target, inputNum); this.OutputBox.Text = output.ToString(); }
public double Handle(String target, int inputNum) { if (handleType.Equals(target)) { // return here means we stop the chain push value up the chain return(Convert(inputNum)); } if (next != null) { //didn't hit so go down the chain and see if another handler hits return(next.Handle(target, inputNum)); } else { // none hit so 0.0 or error return(0.0); } }