Exemple #1
0
 private void searchButton_Click(object sender, EventArgs e)
 {
     // TODO - if object entered exists in list show it
     try
     {
         players playr = teamList.Find(x => x.name == searchInput.Text);
         outputLabel.Text = playr.name + " " + playr.age;
     }
     catch
     {
         // TODO - else show not found message
         outputLabel.Text = "Player not found.";
     }
 }
Exemple #2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            // TODO - gather all information from screen
            string name     = nameInput.Text;
            int    age      = Convert.ToInt32(ageInput.Text);
            string team     = teamInput.Text;
            string position = positionInput.Text;

            // TODO - create object with gathered information
            players newplayer = new players(name, age, team, position);

            newplayer.name     = (nameInput.Text);
            newplayer.age      = Convert.ToInt32(ageInput.Text);
            newplayer.team     = teamInput.Text;
            newplayer.position = (positionInput.Text);

            // TODO - add object to global list
            teamList.Add(newplayer);

            // TODO - display message to indicate addition made
            outputLabel.Text = "Player added.";
        }