Advertisement
Guest User

Untitled

a guest
Feb 12th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. import java.io.FileNotFoundException;
  2. import java.io.IOException;
  3. import java.util.Scanner;
  4.  
  5. public class DriverClass {
  6.  
  7. public static void main(String[] args) throws IOException, ClassNotFoundException {
  8. int choice = 0;
  9. String username, password;
  10. FacebookUser fu0;
  11. try {
  12. fu0 = FacebookUser.readFile();
  13. } catch (FileNotFoundException e) {
  14. fu0 = new FacebookUser("Robert", "password1");
  15. }
  16. while (choice != 9) {
  17. System.out.println(
  18. "1. List Users \n2. Add a User \n3. Delete a User \n4. Get Password Hint \n5. Add Friend \n6. Delete Friend \n7. List Friends \n8. Recommend Friends \n9. Quit");
  19. Scanner s = new Scanner(System.in);
  20. choice = s.nextInt();
  21.  
  22. switch (choice) {
  23. case 1:
  24. System.out.println(fu0.getFriends());
  25. break;
  26. case 2:
  27. System.out.println("Username: ");
  28. s.nextLine();
  29. username = s.nextLine();
  30. fu0.friend(username);
  31. break;
  32. case 3:
  33. System.out.println("Username: ");
  34. s.nextLine();
  35. username = s.nextLine();
  36. fu0.defriend(username);
  37. break;
  38. case 4:
  39. System.out.println("Username: ");
  40. s.nextLine();
  41. username = s.nextLine();
  42. fu0.getPasswordHelp(username);
  43. break;
  44. case 5:
  45. System.out.println("Username of user being added to: ");
  46. s.nextLine();
  47. username = s.nextLine();
  48. System.out.println("Password of user being added to: ");
  49. password = s.nextLine();
  50. fu0.friend(username, password);
  51. break;
  52. case 6:
  53. System.out.println("Username of user removing friend: ");
  54. s.nextLine();
  55. username = s.nextLine();
  56. System.out.println("Password of user removing friend: ");
  57. password = s.nextLine();
  58. fu0.defriend(username, password);
  59. break;
  60. case 7:
  61. System.out.println("Username: ");
  62. s.nextLine();
  63. username = s.nextLine();
  64. System.out.println("Password: ");
  65. password = s.nextLine();
  66. fu0.listFriends(username, password);
  67. break;
  68. case 8:
  69. System.out.println("Username: ");
  70. s.nextLine();
  71. username = s.nextLine();
  72. System.out.println(fu0.getRecommendations(username));
  73. break;
  74. case 9:
  75. FacebookUser.writeToFile(fu0);
  76. break;
  77. }
  78. }
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement