|
-- Posted by ana at 10:02 am on Aug. 11, 2006
I've been trying to learn Java from a book (because for some reason, I thought it was a good idea). It told me to make a file called VolcanoRobot.Java and put this in it: | Code: | class VolcanoRobot { String status; int speed; float temperature; void checkTemperature() { if (temperature > 660) { status = "returning home"; speed = 5; } } void showAttributes() { System.out.println("status: " + status); System.out.println("Speed: " + speed); System.out.println("Temperature: " + temperature); } } | And then it says to make another file called VolcanoApplication.Java which has this inside: | Code: | class VolcanoApplication { public static void main(String[] arguments) { VolcanoRobot dante = new VolcanoRobot(); dante.status = "exploring"; dante.speed = 2; dante.temperature = 510; dante.showAttributes(); System.out.println("Increasing speed to 3."); dante.speed = 3; dante.showAttributes(); System.out.println("Changing temperature to 670."); dante.temperature = 670; dante.showAttributes(); System.out.println("Checking the temperature."); dante.checkTemperature(); dante.showAttributes(); } } | When I try and compile the application, I get the following errors: | Code: | Ana:~ Ana$ javac desktop/Java/VolcanoApplication.Java desktop/Java/VolcanoApplication.Java:3: cannot find symbol symbol : class VolcanoRobot location: class VolcanoApplication VolcanoRobot dante = new VolcanoRobot(); ^ desktop/Java/VolcanoApplication.Java:3: cannot find symbol symbol : class VolcanoRobot location: class VolcanoApplication VolcanoRobot dante = new VolcanoRobot(); ^ 2 errors | WHICH IS REALLY ANNOYING SINCE I DID EXACTLY WHAT THE BOOK SAID! I even copied the code off their website so I could make sure the problem was with the code, not something I'd done wrong... Anyway, since that didn't work, I then combined the two files which let me compile it without a problem but it wouldn't let me run the program... This is reeeeeeeeeallllllllllly annoying. Can someone help? Please?
|