Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.util.Scanner;
- public class DriverClass {
- public static void main(String[] args) throws IOException, ClassNotFoundException {
- int choice = 0;
- String username, password;
- FacebookUser fu0;
- try {
- fu0 = FacebookUser.readFile();
- } catch (FileNotFoundException e) {
- fu0 = new FacebookUser("Robert", "password1");
- }
- while (choice != 9) {
- System.out.println(
- "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");
- Scanner s = new Scanner(System.in);
- choice = s.nextInt();
- switch (choice) {
- case 1:
- System.out.println(fu0.getFriends());
- break;
- case 2:
- System.out.println("Username: ");
- s.nextLine();
- username = s.nextLine();
- fu0.friend(username);
- break;
- case 3:
- System.out.println("Username: ");
- s.nextLine();
- username = s.nextLine();
- fu0.defriend(username);
- break;
- case 4:
- System.out.println("Username: ");
- s.nextLine();
- username = s.nextLine();
- fu0.getPasswordHelp(username);
- break;
- case 5:
- System.out.println("Username of user being added to: ");
- s.nextLine();
- username = s.nextLine();
- System.out.println("Password of user being added to: ");
- password = s.nextLine();
- fu0.friend(username, password);
- break;
- case 6:
- System.out.println("Username of user removing friend: ");
- s.nextLine();
- username = s.nextLine();
- System.out.println("Password of user removing friend: ");
- password = s.nextLine();
- fu0.defriend(username, password);
- break;
- case 7:
- System.out.println("Username: ");
- s.nextLine();
- username = s.nextLine();
- System.out.println("Password: ");
- password = s.nextLine();
- fu0.listFriends(username, password);
- break;
- case 8:
- System.out.println("Username: ");
- s.nextLine();
- username = s.nextLine();
- System.out.println(fu0.getRecommendations(username));
- break;
- case 9:
- FacebookUser.writeToFile(fu0);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement