This will be the last method we add to the game. It handles the information updates and also updates the labels in the GUI. Let's add it by going through the following steps:
- In the WhackABox project, open the MainPage.xaml.cs file.
- Add a method called StatsUpdated() anywhere in the code, as shown in the following code snippet:
private void StatsUpdated(Game sender, GameStats stats)
{
boxCountLabel.Text = stats.NumberOfBoxes.ToString();
planeCountLabel.Text = stats.NumberOfPlanes.ToString();
}
The method receives the GameStats object that we sent and updates the two labels in the GUI.