-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
38 lines (38 loc) · 1.25 KB
/
Main.java
File metadata and controls
38 lines (38 loc) · 1.25 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
/**
* Tests class ContactList by creating
* an object for it and calls its methods
* based on user selection. //RS
*/
import java.util.Scanner;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{ //JJ
int choose; //RS
boolean programKeepGoing = true; //RS
Scanner scanner = new Scanner(System.in); //RS
ContactList list = new ContactList(); //RS
String file = "ContactList.dat"; //JJ
list.readFromDisk(file); //JJ
while (programKeepGoing == true) { //RS and JJ
System.out.println("\n"+"[1] Add contact");
System.out.println("[2] View all contacts");
System.out.println("[3] Find contact by last name");
System.out.println("[4] Exit and Save");
System.out.print("Choose: ");
choose = scanner.nextInt();
switch (choose) { //JJ and RS
case 1: list.addContact();
break;
case 2: list.viewContacts();
break;
case 3: list.findContact();
break;
case 4: list.saveToDisk(file);
programKeepGoing = false;
break;
default: System.out.println("Error, choices must"
+ " be from 1-4");
}
}
}
}