forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from Ruizhi2001/branch-SortStallByLocationOrR…
…ating Branch sort stall by location or rating
- Loading branch information
Showing
27 changed files
with
456 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/seedu/address/logic/commands/SortStallLocationCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STALLS; | ||
|
||
import seedu.address.model.Model; | ||
|
||
/** | ||
* Sorts all stalls by location in alphabetical order. | ||
*/ | ||
public class SortStallLocationCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "sort-stalls-locations"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Sorts all stalls by location in alphabetical order." | ||
+ "and displays them as a list with index number.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
|
||
public static final String MESSAGE_SUCCESS = "Sorted all stalls by location in alphabetical order."; | ||
|
||
@Override | ||
public CommandResult execute(Model model) { | ||
requireNonNull(model); | ||
model.updateFilteredStallList(PREDICATE_SHOW_ALL_STALLS); | ||
model.sortStallLocation(); | ||
return new CommandResult(MESSAGE_SUCCESS, false, false, false, false); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/seedu/address/logic/commands/SortStallRatingCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STALLS; | ||
|
||
import seedu.address.model.Model; | ||
|
||
/** | ||
* Sorts all stalls by location in alphabetical order. | ||
*/ | ||
public class SortStallRatingCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "sort-stalls-ratings"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Sorts all stalls by rating in descending order." | ||
+ "and displays them as a list with index number.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
|
||
public static final String MESSAGE_SUCCESS = "Sorted all stalls by rating in descending order."; | ||
|
||
@Override | ||
public CommandResult execute(Model model) { | ||
requireNonNull(model); | ||
model.updateFilteredStallList(PREDICATE_SHOW_ALL_STALLS); | ||
model.sortStallRating(); | ||
return new CommandResult(MESSAGE_SUCCESS, false, false, false, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/seedu/address/model/stall/StallLocationComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package seedu.address.model.stall; | ||
|
||
import java.util.Comparator; | ||
|
||
/** | ||
* Compares two stalls based on their locations. | ||
*/ | ||
public class StallLocationComparator implements Comparator<Stall> { | ||
@Override | ||
public int compare(Stall stall1, Stall stall2) { | ||
return stall1.getLocationString().compareTo(stall2.getLocationString()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/seedu/address/model/stall/StallRatingComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package seedu.address.model.stall; | ||
|
||
import java.util.Comparator; | ||
|
||
/** | ||
* Compares two stalls based on their ratings. | ||
*/ | ||
public class StallRatingComparator implements Comparator<Stall> { | ||
@Override | ||
public int compare(Stall stall1, Stall stall2) { | ||
return stall2.getStallRatingValue() - stall1.getStallRatingValue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.