Skip to content

Commit

Permalink
Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
danadi7 committed Sep 15, 2020
1 parent 8cd67b5 commit 07ecdbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 86 deletions.
57 changes: 4 additions & 53 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
package duke;

import java.io.IOException;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import duke.exceptions.DukeException;
import duke.logic.CommandParser;
import duke.logic.commands.Command;
Expand All @@ -34,15 +19,6 @@ public class Duke {
private TaskManager tm;
private Ui ui;

private ScrollPane scrollPane;
private VBox dialogContainer;
private TextField userInput;
private Button sendButton;
private Scene scene;

private Image user = new Image(this.getClass().getResourceAsStream("/images/User.jpg"));
private Image duke = new Image(this.getClass().getResourceAsStream("/images/Duke.jpg"));

/**
* Constructor for Duke class.
* Initiates the User Interface and tries to load save file from disk.
Expand All @@ -59,26 +35,11 @@ public Duke() {
}

/**
* This is the method that processes user input and looks out for the exit signal.
* Generates response to command input.
*
* @param input String input by user.
* @return Response after command is executed.
*/
public void run() {
ui.showWelcome();;
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
ui.showLine();
Command c = CommandParser.parse(fullCommand);
c.execute(tm, ui, storage);
isExit = c.isExit();
} catch (DukeException e) {
ui.showError(e);
} finally {
ui.showLine();
}
}
}

public String getResponse(String input) {
try {
Command c = CommandParser.parse(input);
Expand All @@ -87,14 +48,4 @@ public String getResponse(String input) {
return e.getMessage();
}
}

/**
* This is the main method that runs Duke.
*
* @param args Unused.
* @throws IOException On input error.
*/
public static void main(String[] args) throws IOException {
new Duke().run();
}
}
34 changes: 1 addition & 33 deletions src/main/java/duke/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,8 @@
public class Ui {
static final String WELCOME = "Hello. I am Claude! What may I do for you today?";
static final String GOODBYE = "Goodbye! Hope to see you again soon!";
static final String LINE = "______________________________";
private Scanner sc;

public Ui() {
this.sc = new Scanner(System.in);
}

/**
* Reads command input by user.
*
* @return String to be processed by parser.
*/
public String readCommand() {
if (sc.hasNext()) {
return sc.nextLine();
} else {
return "";
}
}

/**
* Prints a line that serves as a divider.
*/
public void showLine() {
System.out.println(LINE);
}
public Ui() {}

/**
* Prints welcome message.
Expand All @@ -52,14 +28,6 @@ public String showGoodbye() {
return (GOODBYE);
}

/**
* Prints output from a Command.
* @param s String to be printed.
*/
public void showDetails(String s) {
System.out.println(s);
}

/**
* Prints a given ArrayList of Tasks.
* @param taskList ArrayList of Tasks to be printed.
Expand Down

0 comments on commit 07ecdbb

Please sign in to comment.