• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

class and testclass

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot! But wow, is that emberassing! Just a simple syntax prob
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic