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 @@ -9,6 +9,19 @@
*/
public class CityList {
private List<City> 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 addOne(City city) {
if (hasCity(city)) {
throw new IllegalArgumentException();
}
cities.add(city);
}


/**
* This adds a city to the list if the city does not exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@ void testCountCities() {

assertEquals(1, cityList.countCities());
}
}

@Test
void testTwoCities(){
CityList cityList = mockCityList();
cityList.addOne(new City("Regina", "Saskatchewan"));
assertEquals(2,cityList.countCities());
}
}