HI I was wondering what is wrong with this piece of code as it compiles but then
it prints java.lang.null exception in the terminal. and it prompts the red line. I am basically trying to create a ticketoffice class that would store information of 3 users who are only allowed to purchase tickets events for 3 events at most.
question 2:
how do i write a while loop for a switch statement that would terminates when say a command 'f' is entered and also a few other commands.
question 3:
I am supposed to store customer in a SortedLinkedList, which I already did...but I would need a while loop to check to see if the customer being input into the terminal is one of the existing customer and the number of tickets purchase are not more than the available tickets for events.
how do I do that??
public TicketOffice()throws IOException
{
Scanner inFile = new Scanner(new FileReader("H:\\csc2011\\data.txt"));
int numOfEvents = 0;
int numOfClients = 0;
int tickets = 0;
numOfEvents = inFile.nextInt();
inFile.nextLine();
for (int i=1; i<= numOfEvents; i++)
{
String name = inFile.nextLine();
tickets = inFile.nextInt();
Event e = new Event(name, tickets);
lstEvent.add(e);
}
Iterator iter = lstEvent.iterator();
while(iter.hasNext())
{
System.out.println((Event) iter.next());
}
}
many thanks!!