Skip to content

Commit

Permalink
Merge branch 'master' into Ivander-NewTripExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanderjmw committed Oct 27, 2020
2 parents 012e771 + a565585 commit fa27b8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
14 changes: 10 additions & 4 deletions src/main/java/seedu/trippie/command/AddPlaceCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,21 @@ public void execute(Ui ui, TrippieData trippieData) {
}

public void sortPlaceList(List<Place> sortedPlaces) {
for (int i = 0; i < sortedPlaces.size(); i++) {
for (int j = i + 1; j < sortedPlaces.size(); j++) {
Boolean swapped = false;
for (int i = (sortedPlaces.size() - 1); i >= 0; i--) {
for (int j = i - 1; j >= 0; j--) {
if (sortedPlaces.get(i).getPlaceDay() == sortedPlaces.get(j).getPlaceDay()
&& sortedPlaces.get(i).getPlaceStartTime() > sortedPlaces.get(j).getPlaceStartTime()) {
&& sortedPlaces.get(i).getPlaceStartTime() < sortedPlaces.get(j).getPlaceStartTime()) {
Collections.swap(sortedPlaces, i, j);
} else if (sortedPlaces.get(i).getPlaceDay() > sortedPlaces.get(j).getPlaceDay()) {
swapped = true;
} else if (sortedPlaces.get(i).getPlaceDay() < sortedPlaces.get(j).getPlaceDay()) {
Collections.swap(sortedPlaces, i, j);
swapped = true;
}
}
if (swapped == false) {
break;
}
}
}
}
16 changes: 8 additions & 8 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ _________________________________________________________________________
DAY 1: (2023-01-01)
[1] 0200 - 0400 clementi mall
DAY 3: (2023-01-03)
[2] 1200 - 1400 nus and ntu
[3] 1200 - 1400 Apple MBS
[2] 1200 - 1400 Apple MBS
[3] 1200 - 1400 nus and ntu
_________________________________________________________________________
>> _________________________________________________________________________
Noted. I've removed this place from the place list.
Expand All @@ -73,8 +73,8 @@ Now you have 2 places in the list.
_________________________________________________________________________
>> _________________________________________________________________________
DAY 3: (2023-01-03)
[1] 1200 - 1400 nus and ntu
[2] 1200 - 1400 Apple MBS
[1] 1200 - 1400 Apple MBS
[2] 1200 - 1400 nus and ntu
_________________________________________________________________________
>> _________________________________________________________________________
Got it. I've added this place:
Expand All @@ -91,8 +91,8 @@ DAY 2: (2023-01-02)
[1] 0700 - 0800 ntu
[2] 1000 - 1200 clementi
DAY 3: (2023-01-03)
[3] 1200 - 1400 nus and ntu
[4] 1200 - 1400 Apple MBS
[3] 1200 - 1400 Apple MBS
[4] 1200 - 1400 nus and ntu
_________________________________________________________________________
>> _________________________________________________________________________
Got it. I've added this place:
Expand All @@ -104,8 +104,8 @@ DAY 2: (2023-01-02)
[1] 0700 - 0800 ntu
[2] 1000 - 1200 clementi
DAY 3: (2023-01-03)
[3] 1200 - 1400 nus and ntu
[4] 1200 - 1400 Apple MBS
[3] 1200 - 1400 Apple MBS
[4] 1200 - 1400 nus and ntu
DAY 5: (2023-01-05)
[5] 1200 - 1400 nus Soc
_________________________________________________________________________
Expand Down

0 comments on commit fa27b8a

Please sign in to comment.