diff --git a/.idea/compiler.xml b/.idea/compiler.xml index b338c3b..add4414 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,7 +6,7 @@ - + diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/Dictionary.java b/src/main/java/Dictionary.java new file mode 100644 index 0000000..b1e7ad0 --- /dev/null +++ b/src/main/java/Dictionary.java @@ -0,0 +1,24 @@ +import java.util.*; + +public class Dictionary { + + List words; + + Dictionary(List words){ + this.words = words; + } + + public Set getUniqueValues(){ + Set values = new HashSet(words); + return values; + } + + public Map getCountOfValues(){ + Map values = new HashMap(); + + for (int i=0;i words = new ArrayList<>(Arrays.asList("cat","dog","lion", + "elephant","gepard","fish", + "fish","cat","dog","dog")); + + Dictionary dictionary = new Dictionary(words); + + System.out.println(dictionary.getUniqueValues()); + System.out.println(dictionary.getCountOfValues()); + + PhoneBook phoneBook = new PhoneBook(); + phoneBook.add("olga", "89233443344"); + phoneBook.add("alice", "89339853344"); + phoneBook.add("alice", "893392345378344"); + + System.out.println(phoneBook.get("alice")); + } + + } diff --git a/src/main/java/PhoneBook.java b/src/main/java/PhoneBook.java new file mode 100644 index 0000000..66646a3 --- /dev/null +++ b/src/main/java/PhoneBook.java @@ -0,0 +1,29 @@ +import java.util.*; + +public class PhoneBook { + + Map> book; + + PhoneBook(){ + book = new HashMap<>(); + } + + void add(String name, String phone){ + if (book.containsKey(name)){ + ArrayList values = book.get(name); + values.add(phone); + book.put(name,values); + }else{ + book.put(name, new ArrayList<>(Arrays.asList(phone))); + } + } + + ArrayList get(String name){ + ArrayList answer = new ArrayList(); + if (book.containsKey(name)){ + answer = book.get(name); + }else{ + System.out.println(""); + }return answer; + } +}