Hi everyone;
My Class has ended and I was not able to solve this problem in time, and I would still like to solve it.
I got these error code.
Exception in thread "main" java.lang.NullP ointerException
at ticketSales.Tic ketSales.makeEv ent(TicketSales .java:185)
at ticketSales.Tic ketInput.main(T icketInput.java :56)
Anyway I have several Class
This one is called TransAction
This is part of my TicketSales Class This is the main section which has all the data types . which has error code
Line 185 is this:
System.out.prin t("Enter Event ID Number (CL123, DL123, PL123) ==>");
id = kbd.next();
This is my TicketInput
This has error code which is at
EventClass ticket = TicketSales.mak eEvent();
Any help would be great. Each Class is it open file.
nomad
My Class has ended and I was not able to solve this problem in time, and I would still like to solve it.
I got these error code.
Exception in thread "main" java.lang.NullP ointerException
at ticketSales.Tic ketSales.makeEv ent(TicketSales .java:185)
at ticketSales.Tic ketInput.main(T icketInput.java :56)
Anyway I have several Class
This one is called TransAction
Code:
public class TransAction {
private TicketSales makeEvent;
private BuyerClass makeBuyer;
public TransAction(TicketSales ticket, BuyerClass buyer) {
this.makeEvent= ticket;
this.makeBuyer= buyer;
}
public TicketSales getTicket() { return makeEvent; }
public BuyerClass getBuyer() { return makeBuyer; }
}
Line 185 is this:
System.out.prin t("Enter Event ID Number (CL123, DL123, PL123) ==>");
id = kbd.next();
Code:
public class TicketSales {
static Scanner kbd;
public static EventClass makeEvent() {
EventClass ticket = null;
// prompt for data
String id;
String en;
String ed;
String vt;
String sl;
double pr;
System.out.print("Enter Event ID Number (CL123, DL123, PL123) ==>");
id = kbd.next();
System.out.print("Enter Event Name (Concert, Dinner, Play) ==>");
en = kbd.next();
System.out.print("Enter Event Date (05/12/2007) ==>");
ed = kbd.next();
System.out.print("Enter Event Time (4:00pm==>");
vt = kbd.next();
System.out.print("Enter Seatlayout (3500, 2000, 1500,==>");
sl = kbd.next();
System.out.print("Enter Price (100.00)==>");
pr = kbd.nextDouble();
// make an object
ticket = new EventClass(id, en, ed, vt, sl, pr);
return ticket;
}
}// close TicketSales
This has error code which is at
EventClass ticket = TicketSales.mak eEvent();
Code:
class TicketInput {
public static void main(String args[]) {
// make array list object
ArrayList<EventClass> arlist = new ArrayList<EventClass>();
arlist.add(new EventClass("CL123", "Concert", "05/12/2007", "12:00pm", "3500 Seats", 55.00));
arlist.add(new EventClass("PL123", "Play", "06/14/2007", "2:00pm", "2000 Seats", 75.00));
arlist.add(new EventClass("DL123", "Dinner", "05/29/2007", "7:00pm","1500 Seats", 100.00));
//arlist.addAll((Collection<? extends EventClass>) new EventClass("DL123", "Dinner", "05/29/2007", "7:00pm", 200.00, "Dan Smith", "1234 East ST Fullerton, CA 90000", "Row 1 Seat 14, 15"));
//arlist.addAll((Collection<? extends EventClass>) new EventClass("PL123", "Play", "06/14/2007", "2:00pm", 150.00, "Jon Doe", "1234 East ST", "Row 12 Seat 18, 19"));
System.out.println(arlist);
// make a scanner
Scanner kbd = new Scanner(System.in);
int choice;
System.out.println("Make a Section: ");
System.out.println("1. Enter Event ");
System.out.println("2. Enter Buyer Info ");
System.out.println("3. Print Event ");
System.out.println("4. Print Buyer Inof ");
System.out.println("5. Exit this Program ");
System.out.print("\nPlease press Enter afer each response");
System.out.println("\nEnter your choose please: ");
choice = kbd.nextInt();
kbd.nextLine();
if (choice == 1) { // if 1 is select go to makeEvent
boolean endData = false;
while (!endData) {
EventClass ticket = TicketSales.makeEvent();
arlist.add(ticket);
System.out.println("Add More Events (Y/N)-->");
String ans = kbd.next();
if (ans.equalsIgnoreCase("N")) {
System.out.println(ticket);
endData = true;
}
}// close while loop
}// close choice 1
....
nomad
Comment