Results 1 to 4 of 4
  1. #1
    OurOhnlyHope is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Post Sokoban java tutorial error- How can I fix it?

    I've been trying to replicate a java-based game creation tutorial on Sokoban that I found online, but Netbeans continues to give me errors concerning the following passage:

    Java Code:
        public void move(int x, int y) {
            int nx = this.x() + x;
            int ny = this.y() + y;
            this.setX(nx);
            this.setY(ny);
    }
    Specifically, netbeans tells me that the "this.setX(nx);" and "this.setY(ny);" parts of the code have no symbols.

    Java Code:
    cannot find symbol
     symbol: method setX(int)

    From what I can discern with my newbie grace, this causes a glitch when running the program that results in crash the moment a directional key is input.This piece of code is located at the end of both the Player and Baggage classes, so It's not something I can just edit out.

    For those of you who are interested, the exact error is "Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: sokoban.Player.setX".

    What can I edit or add to the code that will stop this error I am receiving? Or is my copy of Netbeans just a broken pile of junk? It would help if you can be specific in your answer since I have a rudimentary knowledge of java, at best.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,861
    Rep Power
    19

    Default Re: Sokoban java tutorial error- How can I fix it?

    Your code does not compile because the Player class does not have setX(int) or setY(int) methods.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    OurOhnlyHope is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default Re: Sokoban java tutorial error- How can I fix it?

    Alright... what methods should I use instead? Should I declare X or Y a variable?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,861
    Rep Power
    19

    Default Re: Sokoban java tutorial error- How can I fix it?

    What does the tutorial expect you to do?
    If it expects you to have setX and setY methods then write them.
    They usually take the form:
    Java Code:
    public void setX(int x) {
       this.x = x;
    }
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 04-06-2012, 08:24 PM
  2. BufferedReader error (Stanford tutorial)
    By Jossos in forum New To Java
    Replies: 4
    Last Post: 11-27-2011, 12:01 AM
  3. Error Using Email Client tutorial from Java-Tips
    By lasyn in forum AWT / Swing
    Replies: 6
    Last Post: 09-28-2011, 08:41 PM
  4. Error from a beginners tutorial
    By freelance84 in forum New To Java
    Replies: 3
    Last Post: 07-22-2011, 04:39 PM
  5. Replies: 8
    Last Post: 06-15-2011, 05:26 AM

Posting Permissions

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