diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 000000000..681f41ae2
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 000000000..d291b3d7c
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 000000000..7f68460d8
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..e52c153ea
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,61 @@
+language: android
+jdk: oraclejdk8
+
+env:
+ global:
+ - ANDROID_TARGET=android-22
+ - ANDROID_ABI=armeabi-v7a
+
+android:
+ components:
+ # Uncomment the lines below if you want to
+ # use the latest revision of Android SDK Tools
+ - tools
+ - platform-tools
+
+ # The BuildTools version used by your project
+ - build-tools-23.0.3
+
+ # The SDK version used to compile your project
+ # TODO: why is this here explicitly in addition to $ANDROID_TARGET below
+ - android-23
+
+ # Additional components
+ - extra-google-google_play_services
+ - extra-google-m2repository
+ - extra-android-m2repository
+
+ # The SDK version used to compile your project
+ - $ANDROID_TARGET
+
+ # Specify at least one system image,
+ # if you need to run emulator(s) during your tests.
+ # The line should look like this after interpolation:
+ # - sys-img-armeabi-v7a-android-22
+ - sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
+
+licenses:
+ - 'android-sdk-license-.+'
+
+before_install:
+ # Accept sdk licenses
+ - yes | sdkmanager "platforms;android-29"
+
+ # Get gradle
+ - chmod +x gradlew
+ - wget http://services.gradle.org/distributions/gradle-5.3-bin.zip
+ - unzip -qq gradle-5.3-bin.zip
+ - export GRADLE_HOME=$PWD/gradle-5.3
+ - export PATH=$GRADLE_HOME/bin:$PATH
+
+ # Build the project
+ - gradle -v
+
+ # Start the emulator
+ - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
+ - emulator -avd test -no-skin -no-audio -no-window &
+ - android-wait-for-emulator
+ - adb shell input keyevent 82 &
+
+ # The app will now automatically be installed and tested via
+ # the command `gradle connectedCheck`
diff --git a/app/build.gradle b/app/build.gradle
index 0d17b9380..847098177 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,29 +1,34 @@
-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 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'
+ }
+ }
+ compileOptions {
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ 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.3.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..47bd794f4 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 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..6da242f3e
--- /dev/null
+++ b/app/src/main/java/com/example/simpleparadox/listycity/CityList.java
@@ -0,0 +1,80 @@
+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 (hasCity(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;
+ }
+
+ /**
+ * This method checks to see if a city already exists in the list
+ * @param city
+ * City to check
+ * @return
+ * Return true if the city exists already
+ */
+ public boolean hasCity(City city) {
+ for (City c : cities) {
+ if (c.getCityName().equals(city.getCityName()) &&
+ c.getProvinceName().equals(city.getProvinceName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Delete the city from the list if it is there
+ * @param city
+ * Candidate city to delete
+ */
+ public void delete(City city) {
+ if (!hasCity(city)) {
+ throw new IllegalArgumentException();
+ }
+
+ for (City c : cities) {
+ if (c.compareTo(city) == 0){
+ cities.remove(c);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Return the size of the city list
+ * @return
+ * Size of city list
+ */
+ public int countCities() {
+ return cities.size();
+ }
+}
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..787eab7e0
--- /dev/null
+++ b/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java
@@ -0,0 +1,96 @@
+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.countCities());
+
+ cityList.add(new City("Regina", "Saskatchewan"));
+
+ assertEquals(2, cityList.countCities());
+ assertTrue(cityList.hasCity(new City("Regina", "Saskatchewan")));
+ }
+
+ @Test
+ void testAddException() {
+ CityList cityList = mockCityList();
+
+ City city = new City("Yellowknife", "Northwest Territories");
+ cityList.add(city);
+
+ assertThrows(IllegalArgumentException.class, () -> {
+ cityList.add(city);
+ });
+ }
+
+ @Test
+ void testHasCity() {
+ CityList cityList = mockCityList();
+
+ assertTrue(cityList.hasCity(mockCity()));
+ }
+
+ @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 testDeleteCity() {
+ CityList cityList = mockCityList();
+
+ City city = new City("Victoria", "British Columbia");
+ cityList.add(city);
+
+ assertEquals(2, cityList.countCities());
+
+ cityList.delete(mockCity());
+
+ assertEquals(1, cityList.countCities());
+ assertEquals(0, city.compareTo(cityList.getCities().get(0)));
+ }
+
+ @Test
+ void testDeleteException() {
+ CityList cityList = mockCityList();
+
+ cityList.delete(mockCity());
+
+ assertThrows(IllegalArgumentException.class, () -> {
+ cityList.delete(mockCity());
+ });
+ }
+
+ @Test
+ void testCountCities() {
+ CityList cityList = mockCityList();
+
+ assertEquals(1, cityList.countCities());
+ }
+}
\ No newline at end of file
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..edca88651 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,18 @@
-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.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * 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..aec661f68 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:3.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755