-
Notifications
You must be signed in to change notification settings - Fork 1
/
PersonClient.java
78 lines (77 loc) · 3.33 KB
/
PersonClient.java
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
67
68
69
70
71
72
73
74
75
76
77
78
import java.util.*;
import java.io.*;
public class PersonClient{
private PersonRead nice;
public static void main(String args[])throws Exception{
/*Person john = new Person("John");
Person elizabeth = new Person("Elizabeth");
Person jack = new Person("Jack");
Person molly = new Person(elizabeth, john, "Molly");
Person sam = new Person(molly, jack, "Sam");*/
System.out.println("Loading Database. Please stand by!");
PersonRead nice = new PersonRead("tudor.dat");
nice.load();
menu(nice);
}
public static void menu(PersonRead nice){
Scanner scan =new Scanner(System.in);
String x="";
System.out.println("Welcome to the Tudor Family Database. Choose one of the following options below. Type \"quit\" when you want to quit.");
System.out.println("Choose one of the following options:");
System.out.println("Type \"getParents\" to get the parent lines of a person. Type \"getName\" to search up a person if he exists in the database.");
System.out.println("Type \"addPerson\" to add new people to the database (Coming soon) and type \"reload\" to refresh the database file (Coming Soon).");
while(!x.equals("quit")){
x=scan.nextLine();
if(x.equals("getParents")){
getParents(nice);
}else if(x.equals("getName")){
getName(nice);
}else if(x.equals("addPerson")||x.equals("reload")){
System.out.println("Not available yet!. Type \"help\" to see available options.");
}else if(x.equals("help")){
help();
}else if(x.equals("quit")){
System.out.println("Ok... Quitting...");
System.out.println("Thanks for using the Tudor Family Database Client!");
}else{
System.out.println("Not an option. Type \"help\" to see available options.");
}
}
}
public static void getParents(PersonRead nice){
Scanner scan =new Scanner(System.in);
String x="";
while(!x.equals("back")){
System.out.println("Type a name to get either their maternal or paternal family line. Type \"back\" to go back.");
x=scan.nextLine();
String name = x;
if (x.equals("back")){
break;
}
System.out.println("To search maternal, type \"m\". To search paternal, type \"p\". Type \"back\" to go back.");
x=scan.nextLine();
if(nice.find(name)==null){
System.out.println("Not a vaild name!");
}
else if(x.equals("m")){
nice.find(name).getMaternal();
}else if(x.equals("p")){
nice.find(name).getPaternal();
}else if(x.equals("back")){
break;
}else{
System.out.println("Not a valid option. To search maternal, type \"m\". To search paternal, type \"p\". Type \"back\" to go back.");
}
}
help();
}
public static void help(){
System.out.println("Welcome to the Tudor Family Database. Choose one of the following options below. Type \"quit\" when you want to quit.");
System.out.println("Choose one of the following options:");
System.out.println("Type \"getParents\" to get the parent lines of a person. Type \"getName\" to search up a person if he exists in the database.");
System.out.println("Type \"addPerson\" to add new people to the database (Coming soon) and type \"reload\" to refresh the database file (Coming Soon).");
}
public static void getName(PersonRead nice){
help();
}
}