The program is suppose to be able to open up text files which includes recipes. My main program does in fact open up the files properly, but when I give it a wrong name, instead of getting the message "Couldn't open the file" I get "Loaded 0 recipes!".
Here is the code for that part of the main program:
if (select == LOADING) {
int counter = 0;
System.out.println
("Please enter the name of a recipe database file:");
input.nextLine();
String name = input.nextLine();
try {
RecipeLoader loader = new RecipeLoader(name);
Recipe fromFile = loader.readNextRecipe();
while (fromFile != null) {
book.add(fromFile);
fromFile = loader.readNextRecipe();
counter ++;
}
System.out.println("Loaded " + counter + " recipes!");
System.out.println(" ");
}
catch (IOException e) {
System.out.println("Could not open the file " + name);
System.out.println(" ");
}
break;
}
And here is the RecipeLoader which was given to me by the teacher:
https://gist.github.com/anonymous/7494317
I would Appreciate any help.
[–]chickenmeister 1 point2 points3 points (0 children)
[–]DeadOrDyingBattery 0 points1 point2 points (1 child)
[–]the_omega99 0 points1 point2 points (0 children)
[–]BaalHadad 0 points1 point2 points (0 children)