I am working on a problem for homework in a Java Programming course, and I am stuck. I will tell you upfront that I am by no means an expert, and don't know much about Java or Programming in general.
The issue that I am having is acutally not with a problem for my homework, but with an example from the book that I cannot seem to get to work. The section of the book is titled
WRITING AN APPLICATION THAT USES THE
EventCLASS
The book has the following example in this section that it instructs the student to copy and try in their IDE to see how the concept of an Event class works:
import java.util.Scanner;
public class CreateEventObject
{
public static void main(String[] args)
{
int eventType;
String chosenManager = "";
double chosenRate = 0;
Event scheduledEvent = new Event();
final int PRIVATE_CODE = 1;
final int CORPORATE_CODE = 2;
final int NONPROFIT_CODE = 3;
final String PRIVATE_MANAGER = "Dustin Britt";
final String CORP_MANAGER = "Carmen Lindsey";
final String NONPROFIT_MANAGER = "Robin Armenetti";
final double PRIVATE_RATE = 47.99;
final double CORP_RATE = 75.99;
final double NONPROFIT_RATE = 40.99;
boolean choiceIsGood = true;
Scanner input = new Scanner(System.in);
System.out.println("What type of event are you scheduling?");
System.out.print("Enter " + PRIVATE_CODE + " for private, " + CORPORATE_CODE + " for corporate, or " + NONPROFIT_CODE + " for nonprofit... ");
eventType = input.nextInt();
if(eventType == PRIVATE_CODE)
{
chosenManager = PRIVATE_MANAGER;
chosenRate = PRIVATE_RATE;
}
else
if(eventType == CORPORATE_CODE)
{
chosenManager = CORP_MANAGER;
chosenRate = CORP_RATE;
}
else
if(eventType == NONPROFIT_CODE)
{
chosenManager = NONPROFIT_MANAGER;
chosenRate = NONPROFIT_RATE;
}
else
choiceIsGood = false;
if(choiceIsGood)
{
scheduledEvent.setType(eventType);
scheduledEvent.setManager(chosenManager);
scheduledEvent.setRate(chosenRate);
}
else
System.out.println("You entered " + eventType + " which is invalid.");
System.out.println("Scheduled event:");
System.out.println("Type: " + scheduledEvent.getType() + " Manager: " + scheduledEvent.getManager() + " Rate: " + scheduledEvent.getRate() + " per hour");
}
}
When I try to compile the code above, I get the following error from the IDE:
CreateEventObject.java:12: error: cannot find symbol
Event scheduledEvent = new Event();
^
symbol: class Event
location: class CreateEventObject
CreateEventObject.java:12: error: cannot find symbol
It says the class Event is the issue, but according to the book, that's a valid class...
I am using JGRASP on Windows 7 Professional 64bit and JDK 1.70.
I think it is weird that an example from the book doesn't compile correctly, but it isn't. I am probably missing something really easy, but I can't see anythign that is wrong.
Any help or direction would be appreciated. Thanks in advance for the help.
Event? I'm guessing this class is implemented earlier in the chapter / book - you need that code in your project.importstatement for the Event class.