0

The code I'm trying to compile is:

    class Drumkit {
    boolean topHat = true;
    boolean snare = true;

    void playSnare() {
        System.out.println("bang bang ba-bang");
    }

    void playTopHat() {
        System.out.println("ding ding da-ding");
    }
}

class DrumKitTestDrive {
    public static void main(String[] args) {
        Drumkit d = new DrumKit();
        d.playSnare();
        d.playTopHat();
        d.snare = false;
        if (d.snare == true) {
            d.playSnare();
        }
    }
}

But the output is:

C:\JavaTests>javac DrumKitTestDrive.java
DrumKitTestDrive.java:16: error: cannot find symbol
                Drumkit d = new DrumKit();
                                ^
  symbol:   class DrumKit
  location: class DrumKitTestDrive
1 error

I don't understand why is it wrong? Excuse me if it is a dumb question, but I'm learning and I think the code is alright. Thank you.

Euriloco
  • 253
  • 1
  • 4
  • 9

2 Answers2

1

Just missed to capitalize the k in Drumkit.
Here: Drumkit d = new DrumKit();. Change to this:

Drumkit d = new Drumkit();

Remember that Java is case-sensitive.

Idos
  • 15,053
  • 14
  • 60
  • 75
0

Make sure that DrumKit is imported (if it is not in the same file as the tester) and you change: Drumkit d = new DrumKit(); to Drumkit d = new Drumkit(); because Java is case-sensitive and Drumkit is the name of your class.

Sir Jacob
  • 55
  • 8
  • This is wrong on 2 different levels. – Idos Dec 13 '15 at 19:09
  • for good measure i'll explain: 1. He didn't need to import anything as you can see they are on the same file even... 2. You *always* have a default constructor in java, even if you didn't declare one yourself. – Idos Dec 13 '15 at 19:29
  • My bad on the default constructor but we don't know if he just pasted the code from two different files or if it is like that in actuality. I find it to be better safe than sorry. Also, in his code his Class is called Drumkit; he should do the opposite of the solution you posted correct? – Sir Jacob Dec 13 '15 at 20:31