private void button1_Click(object sender, EventArgs e) { String target = this.TargetUnitBox.Text; int inputNum = Int32.Parse(this.InputUnit.Text); Value output = mileHandler.Handle(target, inputNum); BaseValue baseVal = new BaseValue(output); RoundDecorator rounded = new RoundDecorator(baseVal); ExpDecorator expVal = new ExpDecorator(rounded); TypeDecorator typeVal = new TypeDecorator(output.Type, expVal); String value = typeVal.getValue(); this.OutputBox.Text = value; }
public Value 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 null or error return(null); } }