Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. public static void loadState()
  2. {
  3. try
  4. {
  5. BufferedReader br = new BufferedReader(new FileReader("Logindata.txt"));
  6.  
  7. String tempStr = br.readLine();
  8. String[] totalStr = tempStr.split("#");
  9.  
  10. for (int i = 0; i < totalStr.length; i++)
  11. {
  12. Person tempPer = new Person(totalStr[i]);
  13. if (tempPer.getStatus() == 0)
  14. {
  15. Librarian tempLib = new Librarian(totalStr[i]);
  16. users.add(tempLib);
  17. }
  18. else if (tempPer.getStatus() == 1)
  19. {
  20. User tempUs = new User(totalStr[i]);
  21. users.add(tempUs);
  22. }
  23. }
  24. br.close();
  25.  
  26. BufferedReader br2 = new BufferedReader(new FileReader("Bookdata.txt"));
  27. String tempStr2;
  28. while ((tempStr2 = br2.readLine()) != null)
  29. {
  30. Book tempBook = new Book(tempStr2);
  31. books.add(tempBook);
  32. }
  33. br2.close();
  34. }
  35. catch(Exception e)
  36. {
  37. System.out.println(e);
  38.  
  39. }
  40. }
  41.  
  42. /*_________________________________________
  43. I EN GALAKSE LANGT LANGT VÆK, AKA I EN ANDEN KLASSE */
  44.  
  45. public Person(String fromString)
  46. {
  47. String[] strAr = fromString.split("'");
  48. this.id = Integer.parseInt(strAr[0]);
  49. this.userName = strAr[1];
  50. this.password = strAr[2];
  51. this.status = 3;
  52. }
  53.  
  54.  
  55. // Og så den i user
  56.  
  57. public User(String fromString)
  58. {
  59. super(fromString);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement