From f8267d979f16781db29dc264e625c9fa469b4798 Mon Sep 17 00:00:00 2001 From: Ashikur Rahman <58724901+Ashik-90@users.noreply.github.com> Date: Mon, 29 Nov 2021 00:39:15 +0600 Subject: [PATCH 1/6] testDelete and testDeleteException added --- .../simpleparadox/listycity/CityListTest.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java b/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java index 42106e9bf..e6df8f8c5 100644 --- a/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java +++ b/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java @@ -54,5 +54,30 @@ void testGetCities() { assertEquals(0, city.compareTo(cityList.getCities().get(0))); assertEquals(0, mockCity().compareTo(cityList.getCities().get(1))); } + + @Test + void testDelete() { + CityList cityList = mockCityList(); + + assertEquals(1, cityList.getCities().size()); + + City city = new City("Edmonton", "Alberta"); + cityList.delete(city); + + assertEquals(0, cityList.getCities().size()); + assertFalse(cityList.getCities().contains(city)); + } + + @Test + void testDeleteException() { + CityList cityList = mockCityList(); + + City city = new City("Yellowknife", "Northwest Territories"); + cityList.delete(city); + + assertThrows(IllegalArgumentException.class, () -> { + cityList.delete(city); + }); + } -} \ No newline at end of file +} From b42974a7b9144b55162de3ecba9b4b10a17f3db7 Mon Sep 17 00:00:00 2001 From: Ashikur Rahman <58724901+Ashik-90@users.noreply.github.com> Date: Mon, 29 Nov 2021 00:43:16 +0600 Subject: [PATCH 2/6] delete(city) added --- .../simpleparadox/listycity/CityList.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/example/simpleparadox/listycity/CityList.java b/app/src/main/java/com/example/simpleparadox/listycity/CityList.java index 05b2c1cac..9c4470587 100644 --- a/app/src/main/java/com/example/simpleparadox/listycity/CityList.java +++ b/app/src/main/java/com/example/simpleparadox/listycity/CityList.java @@ -22,6 +22,22 @@ public void add(City city) { cities.add(city); } + /** + * This delete a city to the list if the city exists + * @param city + * This is a candidate city to delete + */ + public void delete(City city) { + if (cities.contains(city)) { + cities.remove(city); + + } + else{ + throw new IllegalArgumentException(); + } + + } + /** * This returns a sorted list of cities * @return From 59029675164ab363f808aba0a69049f057e00f27 Mon Sep 17 00:00:00 2001 From: Ashikur Rahman <58724901+Ashik-90@users.noreply.github.com> Date: Mon, 29 Nov 2021 01:13:21 +0600 Subject: [PATCH 3/6] getcount() added --- .../com/example/simpleparadox/listycity/CityList.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/com/example/simpleparadox/listycity/CityList.java b/app/src/main/java/com/example/simpleparadox/listycity/CityList.java index 9c4470587..9fe0e0f0d 100644 --- a/app/src/main/java/com/example/simpleparadox/listycity/CityList.java +++ b/app/src/main/java/com/example/simpleparadox/listycity/CityList.java @@ -48,5 +48,14 @@ public List getCities() { Collections.sort(list); return list; } + + /** + * This returns a number of cities + * @return + * Return the total sum of city number + */ + public int getCount() { + return cities.size(); + } } From dd4ce8495bd3e9002ba6417a0066dcd45468d5f6 Mon Sep 17 00:00:00 2001 From: Ashikur Rahman <58724901+Ashik-90@users.noreply.github.com> Date: Mon, 29 Nov 2021 01:21:05 +0600 Subject: [PATCH 4/6] TestGetCount() added --- .../simpleparadox/listycity/CityListTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java b/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java index e6df8f8c5..54314aec7 100644 --- a/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java +++ b/app/src/test/java/com/example/simpleparadox/listycity/CityListTest.java @@ -79,5 +79,20 @@ void testDeleteException() { cityList.delete(city); }); } + @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()); + } } From eec38f0f8953234253af30384161ddcb37ce872e Mon Sep 17 00:00:00 2001 From: Ashikur Rahman <58724901+Ashik-90@users.noreply.github.com> Date: Mon, 29 Nov 2021 02:33:15 +0600 Subject: [PATCH 5/6] JavaDoc added --- CityList.html | 373 +++++++++++++++++++++++++++++++++++++++++++ package-summary.html | 164 +++++++++++++++++++ package-tree.html | 155 ++++++++++++++++++ 3 files changed, 692 insertions(+) create mode 100644 CityList.html create mode 100644 package-summary.html create mode 100644 package-tree.html diff --git a/CityList.html b/CityList.html new file mode 100644 index 000000000..43bba5016 --- /dev/null +++ b/CityList.html @@ -0,0 +1,373 @@ + + + + + +CityList + + + + + + + + + + + + + + +
+ +
+ +
+
+ +

Class CityList

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.example.simpleparadox.listycity.CityList
    • +
    +
  • +
+
+
    +
  • +
    +
    public class CityList
    +extends java.lang.Object
    +
    This is a class that keeps track of a list of city objects
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      CityList() 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidadd​(com.example.simpleparadox.listycity.City city) +
      This adds a city to the list if the city does not exist
      +
      voiddelete​(com.example.simpleparadox.listycity.City city) +
      This delete a city to the list if the city exists
      +
      java.util.List<com.example.simpleparadox.listycity.City>getCities() +
      This returns a sorted list of cities
      +
      intgetCount() +
      This returns a number of cities
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CityList

        +
        public CityList()
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        add

        +
        public void add​(com.example.simpleparadox.listycity.City city)
        +
        This adds a city to the list if the city does not exist
        +
        +
        Parameters:
        +
        city - This is a candidate city to add
        +
        +
      • +
      + + + +
        +
      • +

        delete

        +
        public void delete​(com.example.simpleparadox.listycity.City city)
        +
        This delete a city to the list if the city exists
        +
        +
        Parameters:
        +
        city - This is a candidate city to delete
        +
        +
      • +
      + + + +
        +
      • +

        getCities

        +
        public java.util.List<com.example.simpleparadox.listycity.City> getCities()
        +
        This returns a sorted list of cities
        +
        +
        Returns:
        +
        Return the sorted list
        +
        +
      • +
      + + + +
        +
      • +

        getCount

        +
        public int getCount()
        +
        This returns a number of cities
        +
        +
        Returns:
        +
        Return the total sum of city number
        +
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ + + + diff --git a/package-summary.html b/package-summary.html new file mode 100644 index 000000000..e29063670 --- /dev/null +++ b/package-summary.html @@ -0,0 +1,164 @@ + + + + + +com.example.simpleparadox.listycity + + + + + + + + + + + + + + +
+ +
+
+
+

Package com.example.simpleparadox.listycity

+
+
+
    +
  • + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    CityList +
    This is a class that keeps track of a list of city objects
    +
    +
  • +
+
+
+ + + diff --git a/package-tree.html b/package-tree.html new file mode 100644 index 000000000..bf9359e21 --- /dev/null +++ b/package-tree.html @@ -0,0 +1,155 @@ + + + + + +com.example.simpleparadox.listycity Class Hierarchy + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package com.example.simpleparadox.listycity

+
+
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • com.example.simpleparadox.listycity.CityList
    • +
    +
  • +
+
+
+
+ + + From 4a56fc310bd3151458ddd0dc0044de5a65e7967b Mon Sep 17 00:00:00 2001 From: Ashikur Rahman <58724901+Ashik-90@users.noreply.github.com> Date: Mon, 29 Nov 2021 02:39:12 +0600 Subject: [PATCH 6/6] Rename CityList.html to index.html --- CityList.html => index.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CityList.html => index.html (100%) diff --git a/CityList.html b/index.html similarity index 100% rename from CityList.html rename to index.html