Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class and testclass

 
Besjamain Greenaway
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello :-)

I am working throught the head first book, and the subject now is about making a class and testclass. I get the impression that these two files should be seperate, so with one of the exercises I had to do I did;



and the testclass;



When I run it, it seems to compile, but then an error emerges;

DrumkitTestDrive.java:13: cannot find symbol
symbol : method playsnare()
location: class Drumkit
d.playsnare();
^

there's another one that says java:10:.

I've looked on the internet, and get the impression that something is not installed to make it work. Is this true?
 
Henry Wong
author
Marshal
Pie
Posts: 21114
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DrumkitTestDrive.java:13: cannot find symbol
symbol : method playsnare()
location: class Drumkit
d.playsnare();


Java is case sensitive. The method is playSnare(), with a capital S. The compiler can't find one with the lower case s.

Henry
 
Besjamain Greenaway
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot! But wow, is that emberassing! Just a simple syntax prob
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have all made that sort of mistake. You could have written play Snare() instead, which has another error in.

Please don't write "if (d.snare == true) . . ." Write "if(d.snare) . . ." The "== true" is unnecessary. Try it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic