diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 000000000..26d33521a
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 000000000..35ffc652f
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 000000000..a5f05cd8c
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 0d17b9380..c01c18dcc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,29 +1,51 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 29
- buildToolsVersion "29.0.2"
- defaultConfig {
- applicationId "com.example.simpleparadox.listycity"
- minSdkVersion 15
- targetSdkVersion 29
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'androidx.appcompat:appcompat:1.0.2'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
-}
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 30
+ buildToolsVersion "30.0.2"
+ defaultConfig {
+ applicationId "com.example.simpleparadox.listycity"
+ minSdkVersion 15
+ targetSdkVersion 30
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
+ }
+}
+
+tasks.withType(Test) {
+ useJUnitPlatform()
+ testLogging {
+ exceptionFormat "full"
+ events "started", "skipped", "passed", "failed"
+ showStandardStreams true
+ }
+}
+
+task javadoc(type: Javadoc) {
+ source = android.sourceSets.main.java.srcDirs
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+}
+
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.0.1'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
+}
+
diff --git a/app/src/androidTest/java/com/example/simpleparadox/listycity/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/simpleparadox/listycity/ExampleInstrumentedTest.java
index 14b60b236..8ebda9f57 100644
--- a/app/src/androidTest/java/com/example/simpleparadox/listycity/ExampleInstrumentedTest.java
+++ b/app/src/androidTest/java/com/example/simpleparadox/listycity/ExampleInstrumentedTest.java
@@ -1,27 +1,28 @@
-package com.example.simpleparadox.listycity;
-
-import android.content.Context;
-
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
-
- assertEquals("com.example.simpleparadox.listycity", appContext.getPackageName());
- }
-}
+package com.example.simpleparadox.listycity;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+//import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ assertEquals("com.example.simpleparadox.listycity", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/java/com/example/simpleparadox/listycity/City.java b/app/src/main/java/com/example/simpleparadox/listycity/City.java
index fb6fbd1d1..ad43a057c 100644
--- a/app/src/main/java/com/example/simpleparadox/listycity/City.java
+++ b/app/src/main/java/com/example/simpleparadox/listycity/City.java
@@ -1,19 +1,24 @@
-package com.example.simpleparadox.listycity;
-
-public class City {
- private String city;
- private String province;
-
- City(String city, String province){
- this.city = city;
- this.province = province;
- }
-
- String getCityName(){
- return this.city;
- }
-
- String getProvinceName(){
- return this.province;
- }
-}
+package com.example.simpleparadox.listycity;
+
+public class City implements Comparable{
+ private String city;
+ private String province;
+
+ City(String city, String province){
+ this.city = city;
+ this.province = province;
+ }
+
+ String getCityName(){
+ return this.city;
+ }
+
+ String getProvinceName(){
+ return this.province;
+ }
+
+ @Override
+ public int compareTo(City o) {
+ return city.compareTo(o.getCityName());
+ }
+}
diff --git a/app/src/main/java/com/example/simpleparadox/listycity/CityList.java b/app/src/main/java/com/example/simpleparadox/listycity/CityList.java
new file mode 100644
index 000000000..05b2c1cac
--- /dev/null
+++ b/app/src/main/java/com/example/simpleparadox/listycity/CityList.java
@@ -0,0 +1,36 @@
+package com.example.simpleparadox.listycity;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * This is a class that keeps track of a list of city objects
+ */
+public class CityList {
+ private List cities = new ArrayList<>();
+
+ /**
+ * This adds a city to the list if the city does not exist
+ * @param city
+ * This is a candidate city to add
+ */
+ public void add(City city) {
+ if (cities.contains(city)) {
+ throw new IllegalArgumentException();
+ }
+ cities.add(city);
+ }
+
+ /**
+ * This returns a sorted list of cities
+ * @return
+ * Return the sorted list
+ */
+ public List getCities() {
+ List list = cities;
+ Collections.sort(list);
+ return list;
+ }
+
+}
diff --git a/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java b/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java
new file mode 100644
index 000000000..aeb082585
--- /dev/null
+++ b/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java
@@ -0,0 +1,76 @@
+package com.example.simpleparadox.listycity;
+
+import org.junit.jupiter.api.Test;
+
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class CityListTest {
+
+ private CityList mockCityList() {
+ CityList cityList = new CityList();
+ cityList.add(mockCity());
+ return cityList;
+ }
+
+ private City mockCity() {
+ return new City("Edmonton", "Alberta");
+ }
+
+ @Test
+ void testAdd() {
+ CityList cityList = mockCityList();
+
+ assertEquals(1, cityList.getCities().size());
+
+ City city = new City("Regina", "Saskatchewan");
+ cityList.add(city);
+
+ assertEquals(2, cityList.getCities().size());
+ assertTrue(cityList.getCities().contains(city));
+ }
+
+ @Test
+ void testAddException() {
+ CityList cityList = mockCityList();
+
+ City city = new City("Yellowknife", "Northwest Territories");
+ cityList.add(city);
+
+ assertThrows(IllegalArgumentException.class, () -> {
+ cityList.add(city);
+ });
+ }
+
+ @Test
+ void testGetCities() {
+ CityList cityList = mockCityList();
+
+ assertEquals(0, mockCity().compareTo(cityList.getCities().get(0)));
+
+ City city = new City("Charlottetown", "Prince Edward Island");
+ cityList.add(city);
+
+ assertEquals(0, city.compareTo(cityList.getCities().get(0)));
+ assertEquals(0, mockCity().compareTo(cityList.getCities().get(1)));
+ }
+
+ @Test
+ void testGetCount()
+ {
+ CityList cityList = mockCityList();
+
+ assertEquals(0, cityList.getCount());
+
+ City city = new City("Charlottetown", "Prince Edward Island");
+ cityList.add(city);
+ assertEquals(1, cityList.getCount());
+
+ City city2 = new City("Yellowknife", "Northwest Territories");
+ cityList.add(city2);
+ assertEquals(2, cityList.getCount());
+
+
+ }
+
+}
diff --git a/app/src/test/java/com/example/simpleparadox/listycity/ExampleUnitTest.java b/app/src/test/java/com/example/simpleparadox/listycity/ExampleUnitTest.java
index b5f0d24f0..6b2be547f 100644
--- a/app/src/test/java/com/example/simpleparadox/listycity/ExampleUnitTest.java
+++ b/app/src/test/java/com/example/simpleparadox/listycity/ExampleUnitTest.java
@@ -1,17 +1,17 @@
-package com.example.simpleparadox.listycity;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
+package com.example.simpleparadox.listycity;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 5509623ab..cbff3ccd7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.0'
+ classpath 'com.android.tools.build:gradle:7.0.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -25,3 +25,4 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
+
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 36854e580..39b076627 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip