Skip to content

Commit

Permalink
Merge pull request #18 from nazrul0/ui-print
Browse files Browse the repository at this point in the history
Added UI print function
  • Loading branch information
nazrul0 authored Oct 11, 2022
2 parents 0abd628 + eddfe32 commit db6fd97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/seedu/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void processUserInput(String userInput) {
public void executeList() {
executor = new ListCommand(mediaList);
String output = executor.execute();
System.out.println(output);//i think UI should handle the print statement
UI.print(output);

}

Expand Down Expand Up @@ -84,7 +84,7 @@ public void executeAdd(String userInput) {
Movie toAdd = new Movie(name, rating, date);
executor = new AddCommand(mediaList, toAdd);
String output = executor.execute();
System.out.println(output);//i think UI should handle the print statement
UI.print(output);
}
} catch (Exception e) {
System.out.println("\nIncomplete or wrongly formatted command, try again.\n");
Expand All @@ -94,7 +94,7 @@ public void executeAdd(String userInput) {
public void executeClear() {
executor = new ClearCommand(mediaList);
String output = executor.execute();
System.out.println(output);//i think UI should handle the print statement
UI.print(output);
}

public void executeDelete(String[] words) {
Expand All @@ -106,7 +106,7 @@ public void executeDelete(String[] words) {
int deleteIndex = Integer.parseInt(index) - 1;
executor = new RemoveCommand(mediaList, deleteIndex);
String output = executor.execute();
System.out.println(output); //i think UI should handle the print statement
UI.print(output);
}
} catch (Exception e) {
System.out.println("Wrong Command\n");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/duke/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public String getInput(Scanner userInputScanner) {
return userInput;
}

public static void print(String toPrint) {
System.out.println(toPrint);
}

public void printExitGreeting() {
System.out.println("\n---------------\nSee you again!");
}
Expand Down

0 comments on commit db6fd97

Please sign in to comment.