-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplication.java
59 lines (49 loc) · 1.52 KB
/
Application.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
package phoneBook;
public class Application {
public static void main(String[] args) {
Contact[] contactList = new Contact[0];
Contact contact = new Contact();
Address address = new Address();
contact.setAddress(address);
boolean run = true;
while (run) {
switch (DisplayMenu.displayInitialMenu()) {
case 'A': // Add a record
Contact newContact = new Contact();
newContact.setAddress(new Address());
newContact.saveRecord();
contactList = DataHandling.addRecordToArray(newContact, contactList);
break;
case 'D': // Delete a record
contact.deleteRecord(); //Locate a record to delete
contactList = DataHandling.deleteRecordFromArray(contact, contactList);
break;
case 'U': // Update a record
contact.updateRecord(contactList);
contactList = DataHandling.deleteRecordFromArray(contact, contactList);
contactList = DataHandling.addRecordToArray(contact, contactList);
break;
case 'F': // Find a record - first, last, city, state, number
Contact[] foundContacts = contact.findRecord(contactList);
for (Contact c : foundContacts) {
c.display();
}
break;
case 'S': // Show all records
System.out.println(contactList.length);
contactList = Contact.sortRecords(contactList);
for (Contact c : contactList) {
c.display();
}
break;
case 'E': // Exit
run = false;
break;
default:
DisplayMenu.clearScreen();
run = true;
break;
}
}
}
}