Java with Greenfoot Lesson4: Tic-Tac-Toe Game Part III

In this lesson, we will make the Board class check the game progress and stop the game once someone has won. I will then introduce the concept of Java Arrays. We will add code to constantly check whether three game balls of the same color has lined up and to mark those winning game balls.

| | | Next → |

8 thoughts on “Java with Greenfoot Lesson4: Tic-Tac-Toe Game Part III”

  1. Hi,
    I have been learning Java code and I stumbled upon your tutorial to make a Tic Tac Toe Game. So far all the lessons have been very helpful in understanding how Jave code works. I have come across a error in my code tho and I have been trying to figure out what is wrong.

    My error occurs when you add how to figure out the game winning ball. My question to you is, where do I put the code for the winning ball? Because from the lesson I thought you are suppose to put it into the world board class, under the act method. But this brings up and issue because from friends of mine tell me that the world class should not have act methods in the code.

    Thank you,
    Anthony

    • Hi Anthony
      The logic of a winning ball should best be added to an object other than the ball objects. You can either add another class or reuse a non-ball object. I chose to the World object.

    • Yes, you put in the Board class. This is the only class that has access to cell_1, cell_2, etc. Your friends are wrong. There is nothing wrong with having an act() method in a subclass of World.

  2. bis lesson 3 ist alles ok. ab lessen vier läuft das spiel nicht mehr, bekomme die meldung jaya.lang nullpointer. bitte helfen Sie mir weiter.

  3. Hi Folks,
    I have just stumbled over this series and it looks great. However, the sourcecode hyperlinks do not seem to work.

    Any suggestions where I can get the code ?

    Steve

Leave a Reply to fritz Cancel reply