Results 1 to 10 of 10

Thread: Java TicTacToe

  1. #1
    Join Date
    Mar 2007
    Location
    USA
    Posts
    1,433
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default Java TicTacToe

    Hey everyone 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!
    I'm Silent SPY
    Secret project: 0%
    Need help? Send me a PM

  2. #2
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    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:

    Code:
    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:

    Code:
    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

  3. #3
    Join Date
    Mar 2007
    Location
    USA
    Posts
    1,433
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks, Yeah I was going to use an array for the buttons, quite frankly I don't know why i didn't
    I'm Silent SPY
    Secret project: 0%
    Need help? Send me a PM

  4. #4
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Awesome!

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

    Instead of buttons, I chose to draw everything.

    Result:
    There used to be something meaningful here.

  5. #5
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

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

    I will try to answer all Runescape related questions!

  6. #6
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by Imanoobbot View Post
    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
    There used to be something meaningful here.

  7. #7
    Join Date
    Feb 2012
    Location
    Discord
    Posts
    3,114
    Mentioned
    37 Post(s)
    Quoted
    538 Post(s)

    Default

    nice job.

  8. #8
    Join Date
    Nov 2011
    Posts
    122
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    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:


  9. #9
    Join Date
    Mar 2012
    Location
    Over there
    Posts
    840
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

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

  10. #10
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •