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);
        }
Exemple #2
0
        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());
        }
Exemple #3
0
 public abstract string execute(Sportsmen s);
Exemple #4
0
 public string execute(Sportsmen s)
 {
     return(s.Jump());
 }
Exemple #5
0
 public string execute(Sportsmen s)
 {
     return(s.Swim());
 }
Exemple #6
0
 public string execute(Sportsmen s)
 {
     return(s.Run());
 }
Exemple #7
0
 public override string execute(Sportsmen s)
 {
     return(string.Format("%d x %s", count, cmd.execute(s)));
 }