Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Need help with a tic tac toe program

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help with a tic tac toe program

    I just don't even know how to start this. Our teacher is making us make a tic tac toe game for our assignment. What I particularly need help with is how to go about setting up the board and designating the sports the user will use.


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Need help with a tic tac toe program

    I don't think that we'll be able to give you much help until you can tell more details about your problem and ask a more specific question. Also my experience with folks who state "I just don't know how to start..." is that they are much better off if they arrange a meeting with their instructor for some intense face-to-face help.

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with a tic tac toe program

    Okay well one thing in particular I need assistance with is how would I go about assigning X or O to a certain value to be represented by the board.
    - - - is how I set up my board. How can I put X to be in the middle, or on the right, or top right?
    - - -
    - - -

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Need help with a tic tac toe program

    - - -
    - - -
    - - -

    translates to

    [0] [1] [2]
    [3] [4] [5]
    [6] [7] [8]

    translates to

    int[] grid = new int[9]

    translates to

    for(int i = 0; i < grid.length; i++) {
    doSomethingCoolTo(grid[i]);
    }

    translates to

    [0,0] [0,1] [0,2]
    [1,0] [1,1] [1,2]
    [2,0] [2,1] [2,2]

    translates to

    int[][] grid = new int[rows*cols];

    translates to

    for(int i = 0; i < rows; i++) {
    for(int j = 0; j < cols; j++) {
    doSomethingCoolTo(grid[i][j]);
    }
    }

Similar Threads

  1. Replies: 1
    Last Post: July 8th, 2012, 10:23 AM
  2. Program to launch and mirror another program
    By hayate in forum Java Theory & Questions
    Replies: 13
    Last Post: March 9th, 2012, 12:47 AM
  3. Help with class program!!! STUCK! Program not doing what I Want!!!
    By sketch_flygirl in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 4th, 2011, 07:29 AM