• Post Reply Bookmark Topic Watch Topic
  • New Topic

class and classTestDrive  RSS feed

 
Manish Daryani
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written this code but it's not compiling. Can anyone please help. For compiling I'm using the following command

javac DrumKit.java

class DrumKit {
boolean topHat = true;
boolean snare = true;
void playTopHat() {
System.out.println(“ding ding da-ding”);
}
void playSnare() {
System.out.println(“bang bang ba-bang”);
}
}
class DrumKitTestDrive {
public static void main(String[] args) {
DrumKit d = new DrumKit();
d.playSnare();
d.snare = false;
d.playTopHat();
if (d.snare == true) {
d.playSnare();
}
}
}
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you edit your post and add [code] tags please.

Also, can you post the exact error message that you're getting?
 
Manish Daryani
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written this code but it's not compiling. Can anyone please help. For compiling I'm using the following command

javac DrumKit.java

 
Ganesh Patekar
Bartender
Posts: 726
23
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!
You are getting error at System.out.println(“ding ding da-ding”); where you have used pair of single quotes twice to enclose ding ding da-ding message please use double quotes " " NOT '' ''.
You have to compile and run DrumKitTestDrive class as It has main method which is the entry point when you run the program. So compile like javac DrumKitTestDrive .java  and
run like java DrumKitTestDrive
That is only problem, I ran your program successfully.

 
Manish Daryani
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ganesh Patekar wrote:Welcome to CodeRanch!
You are getting error at System.out.println(“ding ding da-ding”); where you have used pair of single quotes twice to enclose ding ding da-ding message please use double quotes " " NOT '' ''.
You have to compile and run DrumKitTestDrive class as It has main method which is the entry point when you run the program. So compile like javac DrumKitTestDrive .java  and
run like java DrumKitTestDrive
That is only problem, I ran your program successfully.



Thank you so much ! It worked !
 
Ganesh Patekar
Bartender
Posts: 726
23
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not good way to check booleanRather
 
Ron McLeod
Bartender
Posts: 1603
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ganesh Patekar wrote:... you have used pair of single quotes twice to enclose ding ding da-ding message please use double quotes

It problem wasn't with single quotes, the code posted was using the left double quotation mark (U+201C) and right double quotation mark (U+201D) rather than plain-old quotation mark (U+0022) characters.

This can happen if you use a word processor rather than a text editor to author your code.
 
Ganesh Patekar
Bartender
Posts: 726
23
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:the code posted was using the left double quotation mark (U+201C) and right double quotation mark (U+201D)
Oh I see, Yes It gave error with 201d and 201c. I thought It was pair of single quotes  
This can happen if you use a word processor rather than a text editor to author your code.
Oh ok, didn't know that. Thank you for correcting me
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!