Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	omni.txt
  • Loading branch information
daryltay415 committed Apr 1, 2024
2 parents 7e8d9de + 5046e1a commit f62593a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
3 changes: 2 additions & 1 deletion omni.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
general / 0 / Go to Paris / 2019-12-12 / 2 hours / / $50
general / 0 / paris / 2023-12-12 / 1 / hello / $50
general / 0 / japan / 2023-12-12 / now / / $100
16 changes: 9 additions & 7 deletions src/main/java/seedu/omnitravel/omnitravel/OmniTravel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ public class OmniTravel {

public static void main(String[] args) throws IOException {
Logger logger = Logger.getLogger("Main");
FileHandler filehandler = new FileHandler("mylog.txt");
SimpleFormatter formatter = new SimpleFormatter();
filehandler.setFormatter(formatter);
logger.addHandler(filehandler);
LogManager.getLogManager().reset();
logger.setLevel(java.util.logging.Level.OFF);
initialiseLogger(logger);
Ui.printGreeting();
FileSave file = new FileSave("omni.txt");
TravelActivityList list = new TravelActivityList();
Expand All @@ -37,7 +32,6 @@ public static void main(String[] args) throws IOException {
assert line != null :"Input does not exist!";
String[] command = line.split(" ");
logger.log(Level.INFO, command[0]);

switch (command[0].toLowerCase()) {
case "list":
Parser.getList(command, list);
Expand Down Expand Up @@ -132,6 +126,14 @@ private static void invokeCommand(String[] command,
}
Ui.printLine();
}
private static void initialiseLogger(Logger logger) throws IOException{
FileHandler filehandler = new FileHandler("mylog.txt");
SimpleFormatter formatter = new SimpleFormatter();
filehandler.setFormatter(formatter);
logger.addHandler(filehandler);
LogManager.getLogManager().reset();
logger.setLevel(java.util.logging.Level.OFF);
}
}


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/omnitravel/storage/FileSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public void loadFileContents(TravelActivityList list) throws FileNotFoundExcepti
String description = line[2];
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 tag =line[5].trim();
String expense =line[6].trim();
TravelActivity activity;
switch (type) {
case "accommodation":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,28 +214,18 @@ public ArrayList<TravelActivity> getTravelActivities () {
*/

public void findTag(String tag){
boolean isFound = false;
int foundCounter = 0;
for (int iterator = 0; iterator < travelActivities.size(); iterator += 1){
if(travelActivities.get(iterator).getTag().contains(tag) &&
!travelActivities.get(iterator).getTag().isEmpty()){
isFound = true;
for (TravelActivity travelActivity : travelActivities) {
if (travelActivity.getTag().contains(tag) &&
!travelActivity.getTag().isEmpty()) {
foundCounter += 1;
if (foundCounter == 1) {
System.out.println("Here are what you are looking for:");
}
Ui.printActivity(travelActivities.get(iterator), foundCounter);
/*
if (travelActivities.get(iterator).getTag() == "") {
System.out.println(foundCounter + ". " + travelActivities.get(iterator).toString());
} else {
System.out.println(foundCounter + ". " + travelActivities.get(iterator).toString() +
" (" + travelActivities.get(iterator).getTag() + ")");
}
*/
Ui.printActivity(travelActivity, foundCounter);
}
}
if (foundCounter == 0 || isFound == false) {
if (foundCounter == 0) {
System.out.println("Sorry I could not find what you are looking for.");
}
}
Expand All @@ -247,20 +237,18 @@ public void findTag(String tag){
*/

public void findType(String type){
boolean isFound = false;
int foundCounter = 0;

for (TravelActivity activity: travelActivities){
if(activity.getClass().getSimpleName().equals(type)){
isFound = true;
foundCounter += 1;
if (foundCounter == 1) {
System.out.println("Here are what you are looking for:");
}
Ui.printActivity(activity, foundCounter);
}
}
if (foundCounter == 0 || isFound == false) {
if (foundCounter == 0) {
System.out.println("Sorry I could not find what you are looking for.");
}
}
Expand Down

0 comments on commit f62593a

Please sign in to comment.