Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public boolean hasCity(City city) {
return true;
}
}

return false;
}

Expand All @@ -69,6 +68,15 @@ public void delete(City city) {
}
}

public void replaceCity(City city, City replacementCity){
for (City c: cities){
if (c == city){
cities.remove(city);
cities.add(replacementCity);
}
}
}

/**
* Return the size of the city list
* @return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.example.simpleparadox.listycity;

import org.junit.jupiter.api.Test;


import static org.junit.jupiter.api.Assertions.*;

class CityListTest {
Expand Down Expand Up @@ -76,6 +74,15 @@ void testDeleteCity() {
assertEquals(0, city.compareTo(cityList.getCities().get(0)));
}

@Test
void testReplaceCity(){
CityList cityList = mockCityList();

City city = new City("Charlottetown", "Prince Edward Island");
cityList.replaceCity(mockCity(), city);
assertEquals(1, cityList.countCities());
}

@Test
void testDeleteException() {
CityList cityList = mockCityList();
Expand Down