private void btnExecute_Click(object sender, EventArgs e) { string sportsmenName = txtSportsmenName.Text.Trim(); StrategyRun run = StrategyRunFactory.make(cbRun.SelectedItem.ToString()); StrategyJump jump = StrategyJumpFactory.make(cbJump.SelectedItem.ToString()); StrategySwim swim = StrategySwimFactory.make(cbSwim.SelectedItem.ToString()); Sportsmen sportsmen = new Sportsmen(sportsmenName, run, jump, swim); SportsmenCommand cmd = (SportsmenCommand)lbCommands.SelectedItem; txtLog.AppendText(sportsmen.execute(cmd) + Environment.NewLine); }
public override string execute(Sportsmen s) { StringBuilder sb = new StringBuilder(); bool first = true; foreach (SportsmenCommand cmd in list) { if (first) { first = false; } else { sb.Append(", "); } sb.Append(cmd.execute(s)); } return(sb.ToString()); }
public abstract string execute(Sportsmen s);
public string execute(Sportsmen s) { return(s.Jump()); }
public string execute(Sportsmen s) { return(s.Swim()); }
public string execute(Sportsmen s) { return(s.Run()); }
public override string execute(Sportsmen s) { return(string.Format("%d x %s", count, cmd.execute(s))); }