Skip to content

Commit

Permalink
fix bug in simplifybill and status
Browse files Browse the repository at this point in the history
  • Loading branch information
Luo-Z-Y committed Apr 16, 2024
1 parent 3892cb9 commit 7e18f91
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
3 changes: 1 addition & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ With Voyagers, you can effortlessly add, delete, and list trips, allowing you to
Links:
* [User Guide](UserGuide.md)
* [Developer Guide](DeveloperGuide.md)
* [About Us](AboutUs.md)
* LUO-Z-Y's Project Portfolio Page: [here](team/luo-z-y.md)
* [About Us](AboutUs.md)
4 changes: 2 additions & 2 deletions local-voyagers.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
main|Beijing|2024-05-01|2024-05-24|CD|go home|UPCOMING
sub|Beijing|2024-05-01|2024-05-01|temp|lorem ipsum|UPCOMING
main|Beijing|2024-05-01|2024-05-24|CD|go home|CANCELLED
sub|Beijing|2024-05-01|2024-05-01|temp|lorem ipsum|CANCELLED
main|Korea|2024-05-01|2024-07-31|Suwon|dating|UPCOMING
main|India|2024-01-01|2024-05-24|CD|go home|ONGOING
17 changes: 17 additions & 0 deletions src/main/java/seedu/voyagers/classes/Trip.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,24 @@ public Status getStatus() {
}

public void setStatus(Status status) {

this.status = status;
if (status == Status.CANCELLED) {
for (Trip subTrip : subTrips) {
subTrip.setStatus(Status.CANCELLED);
}
}
else {
for (Trip subTrip : subTrips) {
if(subTrip.endDate.before(new Date())) {
subTrip.status = Status.COMPLETED;
} else if(subTrip.startDate.after(new Date())) {
subTrip.status = Status.UPCOMING;
} else {
subTrip.status = Status.COMPLETED;
}
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void execute(TripList trips, Ui ui, TripStorage tripStorage) {
trip.setDescription(args[2]);
break;
case "status":
if (args[2].equalsIgnoreCase("cancel")) {
if (args[2].equalsIgnoreCase("cancel")){
trip.setStatus(Status.CANCELLED);
} else if (args[2].equalsIgnoreCase("uncancel")) {
trip.setStatus(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ public void execute(TripList trips, Ui ui, TripStorage tripStorage) {
ui.echo("You have no bills in your list.");
return;
} else {
for (int i = 0; i < trips.size(); i++) {
billList = trips.get(i).getBills();
bills.add(billList.get(i));

}
/*for (int j = 0; j < Objects.requireNonNull(billList).size(); j++) {
Bill billtemp = billList.get(j);
Bill bill = new Bill(billtemp.getName(), billtemp.getPayer(), billtemp.getAmount(),
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/voyagers/utils/TripStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static void readTripFile(ArrayList<Trip> trips, String currentDir, String
Date endDate = format.parse(inputs[3]);
Trip trip = new Trip(inputs[1], startDate, endDate, inputs[4], inputs[5]);
trip.setTripType(inputs[0]);
trip.setStatus(Status.valueOf(inputs[6]));
if (inputs[0].equalsIgnoreCase("main")) {
trips.add(trip);
} else {
Expand Down

0 comments on commit 7e18f91

Please sign in to comment.