Results 1 to 4 of 4
  1. #1
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default need help plzzz for my question

    public void actionPerformed(ActionEvent e) {
    for (int i = 0; i < button.length; i++) {
    for (int j = 0; j < button[i].length; j++) {
    if (e.getSource() == button[i][j]) {
    if (b.getBoard()[i][j] instanceof Atom) {
    deletA(x, y);

    x = i;
    y = j;

    appearA(x, y);
    } else {
    if (b.getBoard()[i][j] instanceof Free) {
    if (i == x && (j - 1) == y) {
    b.move(b.getBoard()[x][y], 'R');
    } else if (y == j && (i + 1) == x) {
    b.move(b.getBoard()[x][y], 'U');
    } else if (i == x && (j + 1) == y) {
    b.move(b.getBoard()[x][y], 'L');
    } else if (y == j && (i - 1) == x) {
    b.move(b.getBoard()[x][y], 'D');




    i make an atomic game and create the board by 2 D array and i need when i click at the atom then to click on the free space the atom and the free space will swap each other

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    What problem(s) are you having with your code so far?

    Do you have a program that compiles yet? If not, make one, compile it and come back with questions about the errors.

    When it compiles, try executing it and come back when you have questions about errors.

  3. #3
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default

    i just want to change the code function to swap the two cells together

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    Sorry, I don't understand what you mean by
    swap the two cells together
    Can you give an example of the data before and after the swap?

    Which line(s) of code you posted are you talking about?

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 09:49 AM
  2. help question
    By 99w210 in forum NetBeans
    Replies: 0
    Last Post: 03-08-2010, 06:23 AM
  3. Question!
    By anjogomez in forum Java Applets
    Replies: 2
    Last Post: 02-21-2009, 04:24 AM
  4. question
    By ayoood in forum Java Software
    Replies: 6
    Last Post: 07-07-2008, 02:32 PM
  5. Question
    By ayoood in forum New To Java
    Replies: 16
    Last Post: 05-21-2008, 03:23 PM

Posting Permissions

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