-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddressBookMain.java
53 lines (47 loc) · 2.06 KB
/
AddressBookMain.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
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Scanner;
public class AddressBookMain {
public static void main(String[] args) {
System.out.println("Welcome to AddressBook Program");
Dictionary dictionary = new Hashtable();
System.out.println("Enter number of addressbooks u want to create");
Scanner scanner = new Scanner(System.in);
int noOfAddressBooks = scanner.nextInt();
for (int i = 0; i < noOfAddressBooks; i++) {
System.out.println("enter name of addressbook");
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
AddressBook addressBooki = new AddressBook();
ContactStore contactStore = new ContactStore();
UserInterface user = new UserInterface();
boolean check = true;
while (check) {
System.out.println(
"Enter choice 1.Add the new contact\n 2.Edit Existing contact\n 3.Remove the contact\n");
int choice = sc.nextInt();
switch (choice) {
case 1 -> {
AddressBook addressBook = new AddressBook();
user.enterDetails(addressBook);
contactStore.add(addressBook);
System.out.println("Contact after adding");
user.print(contactStore.getContactList());
}
case 2 -> {
contactStore.edit();
System.out.println("Contact List after edit");
user.print(contactStore.getContactList());
}
case 3 -> {
contactStore.remove();
System.out.println("Contact List after deletion");
user.print(contactStore.getContactList());
}
default -> check = false;
}
}
dictionary.put(name, addressBooki);
}
}
}