Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- abstract public class Menu
- {
- String filename;
- MenuItem[] MenuList = new MenuItem [100];
- int ItemCount = 0;
- public boolean LoadMenu()
- {
- try // try block
- {
- BufferedReader in = new BufferedReader( // connect to
- new FileReader(filename)); // input file
- String priceString = "";
- String nameString = "";
- double price = 0.0;
- while (in.ready())
- {
- nameString = in.readLine();
- priceString = in. readLine();
- price = Double.parseDouble(priceString);
- MenuList[ItemCount] = new MenuItem(nameString, price);
- ItemCount++;
- }
- }
- catch (Exception anException) // deal with except
- {
- System.err.println("*ERROR*\n" + anException);
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment