-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriver.java
More file actions
66 lines (52 loc) · 2.12 KB
/
Driver.java
File metadata and controls
66 lines (52 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.util.Scanner;
/* Driver.java
* where the program runs
*
* @author Alexis Luo
*/
public class Driver {
public static void main(String[] args) {
//Profile user;
Database database = new Database();
//HashedDictionary profilesList;
Scanner scan = new Scanner(System.in);
boolean runningApp = true;
System.out.println();
System.out.println("| ------ Welcome to facebook! ------ |");
System.out.println();
while (runningApp){
System.out.println("Select an option: ");
System.out.println("(1) Create new profile ");
System.out.println("(2) Login to an existing account ");
System.out.println("(3) Quit program ");
String input = scan.nextLine();
System.out.println();
if (input.equals("1")){ //create new profile
database.createProfile();
}
else if (input.equals("2")){ //login to an existing account
System.out.println("What is your account username?");
String accName = scan.nextLine();
//search for username in hashdictionary
if (database.getProfilesList().contains(accName)){
//username exists! find username profile, then continue with actions
Profile user = database.getProfilesList().getValue(accName);
System.out.println("Successfully logged in!");
System.out.println();
database.loginToProfile(user);
}
else{
System.out.println("Username not found. Try again.");
}
}
else if (input.equals("3")){ //quit program
runningApp = false;
}
else {
System.out.println("Invalid option. Try again. ");
}
}
System.out.println("| --- Thanks for using facebook! --- |");
System.out.println();
}
}