Beispiel #1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            // TODO - gather all information from screen

            // TODO - create object with gathered information
            Player_Info newPlayer = new Player_Info();

            newPlayer.name     = nameInput.Text;
            newPlayer.age      = ageInput.Text;
            newPlayer.team     = teamInput.Text;
            newPlayer.position = positionInput.Text;

            // TODO - add object to global list
            allPlayers.Add(newPlayer);

            // TODO - display message to indicate addition made
            outputLabel.Text = "New player added";
        }
Beispiel #2
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            // This is to be completed in Part II. You will use
            // Lambda Expressions.
            //---------------------------
            outputLabel.Text = "";

            // if object entered exists in list show it
            // else show not found message
            Player_Info search = allPlayers.Find(x => x.name == textBox1.Text);

            if (search == null)
            {
                outputLabel.Text = "No player matches that name";
            }
            else
            {
                outputLabel.Text = "Name:    " + search.name + "\n" + "Age:       " + search.age + "\n" + "Team:     " + search.team + "\n" + "Position: " + search.position;
            }
        }