diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..056b0b3
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..b26911b
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml
new file mode 100644
index 0000000..2888f96
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 0000000..d411041
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 0000000..f58bbc1
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..7134516
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ 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/pom.xml b/pom.xml
index a2f01ef..3b0e4cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,11 @@
+
+ com.google.code.gson
+ gson
+ 2.8.5
+
junit
junit
diff --git a/src/main/java/kz/edu/nu/cs/exercise/ContactList.java b/src/main/java/kz/edu/nu/cs/exercise/ContactList.java
index d69025c..c6652dd 100644
--- a/src/main/java/kz/edu/nu/cs/exercise/ContactList.java
+++ b/src/main/java/kz/edu/nu/cs/exercise/ContactList.java
@@ -1,5 +1,7 @@
package kz.edu.nu.cs.exercise;
+import com.google.gson.Gson;
+
import java.util.ArrayList;
import java.util.List;
@@ -11,8 +13,8 @@ public ContactList() {
}
public static ContactList MakeContactList(String s) {
- // Complete this method, use Gson
- return null;
+ Gson gson = new Gson();
+ return gson.fromJson(s, ContactList.class);
}
public void addContact(MyContact c) {
@@ -24,14 +26,10 @@ public void removeFirstContact() {
}
public MyContact getFirstContact() {
- // complete this method
- // return correct value
- return null;
+ return list.get(0);
}
public int getSize() {
- // complete this method
- // return correct value
- return 0;
+ return list.size();
}
}
diff --git a/src/main/java/kz/edu/nu/cs/exercise/MyContact.java b/src/main/java/kz/edu/nu/cs/exercise/MyContact.java
index e687de7..91baecc 100644
--- a/src/main/java/kz/edu/nu/cs/exercise/MyContact.java
+++ b/src/main/java/kz/edu/nu/cs/exercise/MyContact.java
@@ -1,5 +1,7 @@
package kz.edu.nu.cs.exercise;
+import com.google.gson.Gson;
+
public class MyContact {
private String name;
private int age;
@@ -12,8 +14,8 @@ public MyContact(String name, int age, String number) {
}
public static MyContact MakeMyContact(String s) {
- // complete this method, use Gson
- return null;
+ Gson gson = new Gson();
+ return gson.fromJson(s, MyContact.class);
}
public String getName() {