Java Games with Greenfoot Lesson4: Tic-Tac-Toe GameWrap-up
In this lesson, we will make the Board class check the game progress and stop thegame once someone has won. I will then introduce the concept of Java Arrays. Wewill add code to constantly check whether three game balls of the same color haslined up and to mark those winning game balls.
Step 1: Add isGold(), isSteel(), and isUnclicked() functions tothe Game Ball Class
To check the status of a game, we check the status of each game piece of the gameboard. The status of a game piece in this Tic-Tac-Toe game is: UNCLICKED, GOLD,and STEEL. To allow objects of other classes to check the status of a Game Ballobject, we add three more
functions: isGold(), isSteel(), and isUnclicked(). The access functions of a class are functions to get or set the member variables of that class. The setGold(), setSteel(), and reset() functions that we added in theprevious lessons are also considered as access functions of the GameBall class.