Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+13 votes

I was practicing the practice exam and I got stuck in step 4. Although it's optional, I tried showing the text in the text area. I was guessing we have to use setOnMouseClicked function and show the text in the text area, but I couldn't complete it. If someone has completed step 4, I would love to hear your thought process!

asked in CSC305 Fall 2023 by (1 point)

2 Answers

+6 votes

I tried doing it as well. In an effort to update the points, I created a private method called gameLogTextArea(int pts) and used it inside addPointsToHomeTeam and addPointsToAwayTeam. But I'm completely baffled by what goes in the gameLogTextArea. I'm still struggling with that.

answered by (1 point)
+5 votes

That last part was a bit tricky.

If I recall correctly, you need to store the full log in a String (or even better, a StringBuilder) field within the Game class. Every time the user takes an action that adds points, you need to update that String to include the new message.

Because the data is all stored in the Game class, then even if you go to look at another game and come back to the game, you can set the TextArea's text to match the log text that's associated with the game currently being viewed.

Hope that helps!

answered by (3.5k points)
...