Guest User

Untitled

a guest
May 16th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.io.*;
  2.  
  3.  
  4. abstract public class Menu
  5. {
  6.  
  7. String filename;
  8. MenuItem[] MenuList = new MenuItem [100];
  9. int ItemCount = 0;
  10.  
  11. public boolean LoadMenu()
  12. {
  13. try // try block
  14. {
  15. BufferedReader in = new BufferedReader( // connect to
  16. new FileReader(filename)); // input file
  17. String priceString = "";
  18. String nameString = "";
  19. double price = 0.0;
  20.  
  21. while (in.ready())
  22. {
  23. nameString = in.readLine();
  24. priceString = in. readLine();
  25. price = Double.parseDouble(priceString);
  26.  
  27. MenuList[ItemCount] = new MenuItem(nameString, price);
  28. ItemCount++;
  29. }
  30.  
  31.  
  32. }
  33. catch (Exception anException) // deal with except
  34. {
  35. System.err.println("*ERROR*\n" + anException);
  36. }
  37. return true;
  38. }
  39. }
Add Comment
Please, Sign In to add comment