|
@@ -1,7 +1,88 @@
|
1
|
|
-
|
2
|
|
-
|
|
1
|
+import java.util.*;
|
|
2
|
+import java.util.Scanner;
|
3
|
3
|
/**
|
4
|
|
- * Created by leon on 1/23/18.
|
|
4
|
+ * Write a description of class PhoneBook here.
|
|
5
|
+ *
|
|
6
|
+ * @author (your name)
|
|
7
|
+ * @version (a version number or a date)
|
5
|
8
|
*/
|
6
|
|
-public class PhoneBook {
|
7
|
|
-}
|
|
9
|
+public class PhoneBook{
|
|
10
|
+ Map<List, String> phonebook = new HashMap<>();
|
|
11
|
+ List<String> multipleNumbers = new LinkedList<>();
|
|
12
|
+ // public static boolean electronicPhonebook = true;
|
|
13
|
+ // Scanner input = new Scanner(System.in);
|
|
14
|
+ // Collection<String> c;
|
|
15
|
+ // Iterator<String> iter = c.iterator();
|
|
16
|
+ public PhoneBook(){
|
|
17
|
+ }
|
|
18
|
+ public void add(List multipleNumbers, String name){
|
|
19
|
+ phonebook.put(multipleNumbers, name);
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ public void remove(String name){
|
|
23
|
+ phonebook.remove(name);
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ public String lookup(String name){
|
|
27
|
+ return phonebook.get(name);
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ public String reverseLookup(List number){
|
|
31
|
+ return phonebook.get(number);
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ public void display(){
|
|
35
|
+ System.out.println(" ***** WLECOME TO THE WORLD BOOK ***** ");
|
|
36
|
+ for (Map.Entry<List,String> entry : phonebook.entrySet()){
|
|
37
|
+ System.out.println("Όνομα: \n" + entry.getValue() + "\n" +
|
|
38
|
+ "Αριθμός τηλεφώνου:" + "\n" + entry.getKey() + "\n");
|
|
39
|
+ }
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+ // public void addMultiple(){
|
|
61
|
+ //
|
|
62
|
+ // while(electronicPhonebook = true){
|
|
63
|
+ // System.out.println("Enter a number and then a name. ");
|
|
64
|
+ // String number = input.nextLine();
|
|
65
|
+ // String name = input.nextLine();
|
|
66
|
+ // phonebook.put(number, name);
|
|
67
|
+ //
|
|
68
|
+ // System.out.println("Are you done adding entries¿");
|
|
69
|
+ // String exit = input.nextLine();
|
|
70
|
+ // if (exit.equalsIgnoreCase("yes") || exit.equalsIgnoreCase("yeah") || exit.equalsIgnoreCase("Affirmative")){
|
|
71
|
+ // electronicPhonebook = false;
|
|
72
|
+ // } else
|
|
73
|
+ // if (exit.equalsIgnoreCase("no") || exit.equalsIgnoreCase("nope") || exit.equalsIgnoreCase("nah")){
|
|
74
|
+ // System.out.println("Okay...");
|
|
75
|
+ // } else {System.out.println("I guess not...");
|
|
76
|
+ // }
|
|
77
|
+ // }
|
|
78
|
+ // }
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+ // public static void commandCenter(){
|
|
82
|
+ // PhoneBook runningbook = new PhoneBook();
|
|
83
|
+ // while(electronicPhonebook = true){
|
|
84
|
+ // runningbook.addMultiple();
|
|
85
|
+ // }
|
|
86
|
+ //
|
|
87
|
+ // }
|
|
88
|
+ }
|