Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
Remove magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
JrmCkh committed Mar 28, 2023
1 parent b4a5f83 commit dd6425d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class ShowNextCommand extends Command {

public static final String COMMAND_WORD = "next";
public static final int SHOW_UPCOMING_COUNT_ONE = 1;

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Display upcoming events."
+ "\nCan be used without any parameters."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ezschedule.logic.parser;

import static ezschedule.logic.commands.ShowNextCommand.SHOW_UPCOMING_COUNT_ONE;

import ezschedule.commons.core.Messages;
import ezschedule.logic.commands.ShowNextCommand;
import ezschedule.logic.parser.exceptions.ParseException;
Expand All @@ -20,7 +22,7 @@ public class ShowNextCommandParser implements Parser<ShowNextCommand> {
public ShowNextCommand parse(String userInput) throws ParseException {
// No argument provided, just show the next one
if (userInput.isBlank()) {
return new ShowNextCommand(new UpcomingEventPredicate(1));
return new ShowNextCommand(new UpcomingEventPredicate(SHOW_UPCOMING_COUNT_ONE));
}

try {
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/ezschedule/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import ezschedule.commons.core.GuiSettings;
import ezschedule.model.event.Event;
import ezschedule.model.event.UpcomingEventPredicate;
import javafx.collections.ObservableList;

/**
Expand All @@ -17,11 +16,6 @@ public interface Model {
*/
Predicate<Event> PREDICATE_SHOW_ALL_EVENTS = unused -> true;

/**
* {@code Predicate} that always evaluate to true
*/
Predicate<Event> PREDICATE_SHOW_NEXT_FIRST_EVENT = new UpcomingEventPredicate(1);

/**
* Returns the user prefs.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ezschedule/model/ModelManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ezschedule.model;

import static ezschedule.commons.util.CollectionUtil.requireAllNonNull;
import static ezschedule.logic.commands.ShowNextCommand.SHOW_UPCOMING_COUNT_ONE;
import static java.util.Objects.requireNonNull;

import java.nio.file.Path;
Expand Down Expand Up @@ -38,7 +39,7 @@ public ModelManager(ReadOnlyScheduler scheduler, ReadOnlyUserPrefs userPrefs) {
this.userPrefs = new UserPrefs(userPrefs);
filteredEvents = new FilteredList<>(this.scheduler.getEventList());
upcomingEvents = new FilteredList<>(this.scheduler.getEventList());
updateUpcomingEventList(PREDICATE_SHOW_NEXT_FIRST_EVENT);
updateUpcomingEventList(new UpcomingEventPredicate(SHOW_UPCOMING_COUNT_ONE));
}

public ModelManager() {
Expand Down

0 comments on commit dd6425d

Please sign in to comment.