Search:

Type: Posts; User: Norm

Search: Search took 0.09 seconds.

  1. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    In the action listener for the button, the getSource() method will return a reference to the button that was clicked so you can get its values.


    I don't understand this part. There is only one...
  2. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Do you want to have the button contain the row and col values?
    A couple of ways to do that.
    1)Extent the JButton class with your class that can contain the row and col values that you can get from...
  3. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Can you explain what you want to do with the button that is clicked?
  4. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Do you want to disable the button that was clicked on so it can't send any more events?
    If you cast the object returned by getSource() to a button, you can call the button's methods.
  5. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Does it work when compiled and executed? Does it return the right results?


    It looks better.
  6. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    I added some comments after first post.
  7. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Do you have a question?

    One problem I see is the use of an assignment operator (=) instead of an equality test operator(==)
    Testing a boolean variable for equal to true is redundant. Its value...
  8. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Define which way is forward and then test if the move is in that direction. The near pieces move away from you, the far pieces move towards you.
  9. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Can you explain where you are having a problem with the code? Ask a specific question about it.
  10. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Have a variable like a boolean that says if this is the first move or not.
    Initialize it as true and set it false when the first move is made.
  11. Replies
    21
    Views
    1,881

    Re: isValidMove Method

    Can you determine if its the first move and allow 2 squares if so?
Results 1 to 11 of 11