Exemplo n.º 1
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string           SportsmenName = txtSportsmenName.Text;
            SportsmanCommand item          = (SportsmanCommand)lbCommands.SelectedItem;
            Sportsman        sportsman     = new Sportsman(SportsmenName);
            string           result        = sportsman.Execute(item);

            txtLog.AppendText(result + Environment.NewLine);
            AdjustButtons();
        }
        public override string execute(Sportsman s)
        {
            StringBuilder sb    = new StringBuilder();
            bool          first = true;

            foreach (SportsmanCommand cmd in list)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    sb.Append(", ");
                }
                sb.Append(cmd.execute(s));
            }
            return(sb.ToString());
        }
 public abstract string execute(Sportsman s);
 public string execute(Sportsman s)
 {
     return(s.Jump());
 }
 public string execute(Sportsman s)
 {
     return(s.Swim());
 }
 public string execute(Sportsman s)
 {
     return(s.Run());
 }