SRL Archive - Game Development

Java TicTacToe


Silent

2011-12-12 17:31:09

Hey everyone :rolleyes: I had a Computer Science project that I just completed today, so I thought I'd share the results with you.

The project was quite simple really, it was to make a game of TicTacToe.

Here is the jar file applet, and of course the source code :)

Have fun!

Richard

2011-12-12 19:43:46

Nice to see some Java programming :) I like it, does the job well :)

Couple of things, is the Button class necessary? Besides for it having a different identifier, it is identical to the JButton class.

With the buttons, I would have done it as an array, rather than having 9 separate in the variable declaration. Some similar to below would have instantiated them:


for (Buttons button: buttonArray) //where buttonArray is your array of buttons
button = new Buttons();

It would have also made it easier when making the setTile() method:

public void setTile(Buttons btn){
for (int i = 0; i < 9; i++)
if (buttonArray[i].equals(btn)
tiles[i] = gamePiece;
}

The array would also help in many other methods, and would shorten your code dramatically. I suppose it's all personal preference though, I just prefer to compact things.


Good job though :)

Silent

2011-12-12 20:22:01

Thanks, Yeah I was going to use an array for the buttons, quite frankly I don't know why i didn't :p

Frement

2012-04-01 12:28:07

Awesome! :)

I actually chose the same game for a school project we had to make.

Instead of buttons, I chose to draw everything.

Result:

Imanoobbot

2012-04-10 12:00:45

Haha great! I made the same thing some days ago. But yours looks better! Love it to see Java programmers in here =)

Frement

2012-04-10 12:05:47

From: Imanoobbot
Haha great! I made the same thing some days ago. But yours looks better! Love it to see Java programmers in here =)


I did that project when I had coded with Java for two weeks (Like 4 days, 3 hours per day). And I'm in no way a Java programmer :)

The Killer

2012-04-20 15:28:53

nice job.

Ketan

2012-04-21 04:01:32

Dafuq, I had it as my project as well. In java also. I also made a single player, in which the program itself do moves (O) and that also with intelligence:


Total

2012-05-06 20:24:22

Just did one of these for my VB.Net class final project. Only took like 30 minutes but was fun. :p

P1nky

2012-05-11 03:03:14

Just tested it out, I like it :) Cool maybe one day you can make a even advance game :D