-
May 18th, 2011, 10:16 PM
#1
help!
Im trying to make a program that simulates a vending machine while using stacks and queues, but while sending out the method to add the objects into my linked list I keep getting a null pointer exception. heres the code with MachineRow being an interface and FIFO being a linkedList
public static void loadFIFO(int size, Scanner keyboard, MachineRow FIFO)
throws FileNotFoundException {
System.out.print("Enter filename: ");
String fileopen = keyboard.nextLine();
Scanner inputFile = new Scanner(new File(fileopen));
int j = 0;
while (inputFile.hasNext() && j < size) {
String name = inputFile.nextLine();
String type = inputFile.nextLine();
String upc = inputFile.nextLine();
VendingProduct add = new Product(name, type, upc);
if(FIFO.add(add)==true){
j++;
}
}
}
and heres the method in the FIFORow class
public boolean add(VendingProduct product) {
FIFOrow.addFirst(product);
boolean added=true;
return added;
}
please help if you can!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|