Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2223S1#80 from CFSY/select-command
Browse files Browse the repository at this point in the history
Select command
  • Loading branch information
CFSY authored Oct 22, 2022
2 parents 515dfa2 + 8a99dfa commit 56bb0d1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
/**
* Changes the remark of an existing person in the address book.
*/
public class PlanCommand extends Command {
public static final String COMMAND_WORD = "plan";
public class SelectCommand extends Command {
public static final String COMMAND_WORD = "select";
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": selects an itinerary for planning "
+ "by the index number used in the last itineraries listing.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "Example: " + COMMAND_WORD + " 1 ";
public static final String MESSAGE_ARGUMENTS = "Index: %1$d";
public static final String MESSAGE_PLAN_ITINERARY_SUCCESS = "Planning Itinerary: %1$s";
public static final String MESSAGE_SELECT_ITINERARY_SUCCESS = "Selected Itinerary: %1$s";
private final Index index;

/**
* @param index of the itinerary to plan
* @param index of the itinerary to select
*/
public PlanCommand(Index index) {
public SelectCommand(Index index) {
requireAllNonNull(index);

this.index = index;
Expand Down Expand Up @@ -55,7 +55,7 @@ public CommandResult execute(Model model) throws CommandException {
// instead of going to wish stage by default

// return command result with stage change to wish by default for now (refer above)
return new CommandResult(String.format(MESSAGE_PLAN_ITINERARY_SUCCESS, selectedItinerary.getName()),
return new CommandResult(String.format(MESSAGE_SELECT_ITINERARY_SUCCESS, selectedItinerary.getName()),
Stages.WISH);
}

Expand All @@ -67,12 +67,12 @@ public boolean equals(Object other) {
}

// instanceof handles nulls
if (!(other instanceof PlanCommand)) {
if (!(other instanceof SelectCommand)) {
return false;
}

// state check
PlanCommand e = (PlanCommand) other;
SelectCommand e = (SelectCommand) other;
return index.equals(e.index);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import seedu.waddle.commons.core.index.Index;
import seedu.waddle.commons.exceptions.IllegalValueException;
import seedu.waddle.logic.commands.PlanCommand;
import seedu.waddle.logic.commands.SelectCommand;
import seedu.waddle.logic.parser.exceptions.ParseException;

/**
Expand All @@ -20,7 +20,7 @@ public class PlanCommandParser {
* @return PlanCommand.
* @throws ParseException If the user input does not conform the expected format.
*/
public PlanCommand parse(String args) throws ParseException {
public SelectCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args);

Expand All @@ -29,10 +29,10 @@ public PlanCommand parse(String args) throws ParseException {
index = ParserUtil.parseIndex(argMultimap.getPreamble());
} catch (IllegalValueException ive) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
PlanCommand.MESSAGE_USAGE), ive);
SelectCommand.MESSAGE_USAGE), ive);
}

return new PlanCommand(index);
return new SelectCommand(index);
}
}

4 changes: 2 additions & 2 deletions src/main/java/seedu/waddle/logic/parser/WaddleParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import seedu.waddle.logic.commands.HelpCommand;
import seedu.waddle.logic.commands.HomeCommand;
import seedu.waddle.logic.commands.ListCommand;
import seedu.waddle.logic.commands.PlanCommand;
import seedu.waddle.logic.commands.SelectCommand;
import seedu.waddle.logic.commands.StageCommand;
import seedu.waddle.logic.parser.exceptions.ParseException;

Expand Down Expand Up @@ -95,7 +95,7 @@ public Command parseHomeCommand(String commandWord, String arguments) throws Par
case ListCommand.COMMAND_WORD:
return new ListCommand();

case PlanCommand.COMMAND_WORD:
case SelectCommand.COMMAND_WORD:
return new PlanCommandParser().parse(arguments);

case HomeCommand.COMMAND_WORD:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/ItineraryListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</HBox>
<Label fx:id="country" styleClass="cell_small_label" text="\$country" />
<Label fx:id="startDate" styleClass="cell_small_label" text="\$startDate" />
<Label fx:id="endDate" styleClass="cell_small_label" text="\$endDate" />
<Label fx:id="duration" styleClass="cell_small_label" text="\$duration" />
<Label fx:id="people" styleClass="cell_small_label" text="\$people" />
</VBox>
</GridPane>
Expand Down

0 comments on commit 56bb0d1

Please sign in to comment.