Skip to content

Commit

Permalink
update filesave with location and entertainment
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenKangg committed Apr 5, 2024
1 parent 001d42d commit cd01fdd
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/seedu/omnitravel/storage/FileSave.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package seedu.omnitravel.storage;
import seedu.omnitravel.travelactivitytypes.TravelActivityList;
import seedu.omnitravel.travelactivitytypes.Accommodation;
import seedu.omnitravel.travelactivitytypes.Food;
import seedu.omnitravel.travelactivitytypes.Landmark;
import seedu.omnitravel.travelactivitytypes.TravelActivity;
import seedu.omnitravel.travelactivitytypes.*;

import java.io.FileWriter;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -32,21 +28,25 @@ public void loadFileContents(TravelActivityList list) throws FileNotFoundExcepti
LocalDate date = LocalDate.parse(line[3]);
String duration = line[4];
String tag = line.length >= 6 ? line[5].trim() : "";
String expense = line.length >= 7 ? line[6].trim() : "";
String location = line.length >= 7 ? line[6].trim() : "";
String expense = line.length >= 8 ? line[7].trim() : "";
TravelActivity activity;
switch (type) {
case "accommodation":
activity = new Accommodation(description, date, duration, tag, expense);
activity = new Accommodation(description, date, duration, tag, location, expense);
break;
case "food":
activity = new Food(description, date, duration, tag, expense);
activity = new Food(description, date, duration, tag, location, expense);
break;
case "landmark":
activity = new Landmark(description, date, duration, tag, expense);
activity = new Landmark(description, date, duration, tag, location, expense);
break;
case "general":
activity = new TravelActivity(description, date, duration, tag, expense);
case "entertainment":
activity = new Entertainment(description, date, duration, tag, location, expense);
break;
case "general":
activity = new TravelActivity(description, date, duration, tag, location, expense);
break;
default:
throw new FileNotFoundException("File is corrupted or has invalid format");
}
Expand Down

0 comments on commit cd01fdd

Please sign in to comment.