forked from nus-cs2103-AY2223S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed return type to String so return type can be more easily accessed by the GUI.
- Loading branch information
Showing
22 changed files
with
129 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,41 @@ | ||
package Duke; | ||
|
||
import Duke.commands.Command; | ||
import java.util.ArrayList; | ||
|
||
import java.util.List; | ||
|
||
import Duke.gui.Main; | ||
import javafx.application.Application; | ||
import java.io.IOException; | ||
|
||
|
||
/* Inspiration taken from Bag Devesh Kumar and Zizheng ip to solve some prevalent issues | ||
*/ | ||
public class Duke { | ||
|
||
private final Storage storage; | ||
private final TaskList tasks; | ||
private final Ui ui; | ||
|
||
private Storage storage; | ||
private TaskList tasks; | ||
private Ui ui; | ||
|
||
public Duke() throws IOException { | ||
public Duke() throws IOException, DukeException { | ||
ui = new Ui(); | ||
storage = new Storage(); | ||
tasks = new TaskList(storage.fileToList()); | ||
} | ||
|
||
public void run() { | ||
ui.showLogo(); | ||
boolean isExit = false; | ||
while (!isExit) { | ||
try { | ||
String fullInput = ui.readInput(); | ||
ui.printDash(); | ||
Command c = Parser.parse(fullInput); | ||
List<String> reply = c.execute(tasks, ui, storage); | ||
for (String line : reply) { | ||
ui.printLine(line); | ||
} | ||
isExit = c.isExit(); | ||
} catch (IOException | DukeException e) { | ||
ui.printError(e.getMessage()); | ||
} finally { | ||
ui.printDash(); | ||
} | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
try { | ||
new Duke().run(); | ||
} catch (IOException e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
public String getResponse(String input) throws DukeException, IOException { | ||
Command c = Parser.parse(input); | ||
String message = c.execute(tasks, ui, storage); | ||
return message; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.