Results 1 to 4 of 4
- 05-01-2012, 05:40 PM #1
Member
- Join Date
- May 2012
- Posts
- 3
- Rep Power
- 0
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); }
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.
- 05-01-2012, 06:27 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
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 **
- 05-01-2012, 06:32 PM #3
Member
- Join Date
- May 2012
- Posts
- 3
- Rep Power
- 0
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?
- 05-01-2012, 06:43 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
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
-
Tutorial:Review of Java Design Patterns for the Java Architect Exam
By Java Exam in forum OCMJEAReplies: 0Last Post: 04-06-2012, 09:24 PM -
BufferedReader error (Stanford tutorial)
By Jossos in forum New To JavaReplies: 4Last Post: 11-27-2011, 01:01 AM -
Error Using Email Client tutorial from Java-Tips
By lasyn in forum AWT / SwingReplies: 6Last Post: 09-28-2011, 09:41 PM -
Error from a beginners tutorial
By freelance84 in forum New To JavaReplies: 3Last Post: 07-22-2011, 05:39 PM -
I am getting a cannot find symbol error on this code from Oracle Java tutorial site
By bigsonny in forum New To JavaReplies: 8Last Post: 06-15-2011, 06:26 AM
Bookmarks