Letβs print the selected number in the console.
Unlike the previous messages which were all text, this one will include the value of a variable.
To do it, we need to combine the variable value with the message string.
π Learn
β What to Do
π― Expected Outcome
π¨οΈ Console
+--------------------------------+
+-- Welcome to Odds and Evens! --+
+--------------------------------+
--> Choose 1 for Odds or 2 for Evens:
1
# You chose Odds, Computer is Evens
--> Choose a number between 1 and 2:
1
# You chose: 1
π¨οΈ Console
+--------------------------------+
+-- Welcome to Odds and Evens! --+
+--------------------------------+
--> Choose 1 for Odds or 2 for Evens:
1
# You chose Odds, Computer is Evens
--> Choose a number between 1 and 2:
2
# You chose: 2
βοΈ Program.cs - Changes
// Player enters a number between 1 and 2.
GamePrint.Input("Choose a number between 1 and 2");
int playerNumber = GameInput.Number(1, 2);
++ GamePrint.Message("You chose: " + playerNumber);ποΈ Program.cs - Final
(...)
// Player enters a number between 1 and 2.
GamePrint.Input("Choose a number between 1 and 2");
int playerNumber = GameInput.Number(1, 2);
GamePrint.Message("You chose: " + playerNumber);
(...)