Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2223S1#93 from ciaoosuuu/fix-bugs
Browse files Browse the repository at this point in the history
Fix command bugs
  • Loading branch information
ciaoosuuu authored Oct 25, 2022
2 parents 81c9897 + 2ad0f13 commit 387e09c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/waddle/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public CommandResult execute(Model model) throws CommandException {
}

model.addItinerary(toAdd);
System.out.println("number of days in a newly created itinerary with duration: " + this.toAdd.getDays().size());
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/waddle/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private static Itinerary createEditedItinerary(Itinerary itineraryToEdit,
Date updatedStartDate = editItineraryDescriptor.getStartDate().orElse(itineraryToEdit.getStartDate());
ItineraryDuration updatedDuration = editItineraryDescriptor.getDuration()
.orElse(itineraryToEdit.getDuration());
System.out.println("the updated duration is: " + updatedDuration);
People updatedPeople = editItineraryDescriptor.getPeople().orElse(itineraryToEdit.getPeople());
Budget updatedBudget = editItineraryDescriptor.getBudget().orElse(itineraryToEdit.getBudget());

Expand Down
15 changes: 2 additions & 13 deletions src/main/java/seedu/waddle/model/item/Duration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,15 @@
public class Duration {
public static final String MESSAGE_CONSTRAINTS = "Duration should only contain a positive number.";
private final int duration;
private final boolean isNull;

/**
* Constructs a {@code Duration}.
*
* @param duration A valid duration.
*/
public Duration(String duration) {
if (duration == null) {
this.isNull = true;
this.duration = 0;
} else {
checkArgument(isValidDuration(duration), MESSAGE_CONSTRAINTS);
this.duration = Integer.valueOf(duration);
this.isNull = false;
}
checkArgument(isValidDuration(duration), MESSAGE_CONSTRAINTS);
this.duration = Integer.valueOf(duration);
}

public int getDuration() {
Expand All @@ -45,10 +38,6 @@ public static boolean isValidDuration(String test) {
}
return value >= 0;
}

public boolean isNull() {
return isNull;
}
@Override
public String toString() {
return String.valueOf(duration);
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/seedu/waddle/model/itinerary/Itinerary.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ public Country getCountry() {
return country;
}

/* TODO: implement method
public Date getEndDate() {
return duration.getEndFromStart(startDate);
}
*/

public Date getStartDate() {
return startDate;
}
Expand Down Expand Up @@ -263,10 +257,14 @@ public String toString() {
return builder.toString();
}

public void setDays(List<Day> days) {
for (int i = 0; i < getDuration().getValue(); i++) {
if (i < days.size()) {
this.days.add(i, days.get(i));
public void setDays(List<Day> dayList) {
for (int i = 0; i < dayList.size(); i++) {
if (i < getDuration().getValue()) {
this.days.set(i, dayList.get(i));;
} else {
for (Item item : dayList.get(i).deleteDay()) {
addItem(item);
}
}
}
}
Expand Down

0 comments on commit 387e09c

Please sign in to comment.