Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mark Biju George] iP #306

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
88c8d20
Update Duke.java
markbiju16 Jan 20, 2022
6a2ea62
Update Duke.java
markbiju16 Jan 20, 2022
8d817b0
Update Duke.java
markbiju16 Jan 20, 2022
b8c4536
Level-4
markbiju16 Jan 21, 2022
0eaf074
Level-4 upd
markbiju16 Jan 22, 2022
a5fd6ec
A-TextUiTesting
markbiju16 Jan 22, 2022
0f0b793
Level-5
markbiju16 Jan 26, 2022
3a748c6
Update Duke.java
markbiju16 Jan 26, 2022
f1e27b0
Level-7
markbiju16 Feb 1, 2022
3edf9ae
Level-8
markbiju16 Feb 2, 2022
2466584
Merge branch 'branch-Level-8'
markbiju16 Feb 2, 2022
987ae8f
A-MoreOOP
markbiju16 Feb 5, 2022
91a36da
update A-MoreOOP
markbiju16 Feb 5, 2022
83901c6
Delete AddCommand.java
markbiju16 Feb 11, 2022
ab034ad
A-Packages
markbiju16 Feb 11, 2022
edcb4fc
A-JUnit
markbiju16 Feb 12, 2022
eb2a949
Delete file.txt
markbiju16 Feb 12, 2022
cd19b3c
A-Jar
markbiju16 Feb 12, 2022
a61bb16
branch-A-JavaDoc
markbiju16 Feb 12, 2022
4440da8
branch-A-CodingStandard
markbiju16 Feb 13, 2022
3430097
Level-9
markbiju16 Feb 14, 2022
a502950
Merge branch 'branch-A-CodingStandard'
markbiju16 Feb 14, 2022
5a5a5a0
Merge branch 'branch-Level-9'
markbiju16 Feb 14, 2022
c6b7c86
Merge branch 'add-gradle-support'
markbiju16 Feb 15, 2022
e11f89b
Level-10
markbiju16 Feb 19, 2022
9c12c96
Update Storage.java
markbiju16 Feb 19, 2022
5f2d63d
update Ui
markbiju16 Feb 19, 2022
8255963
Update tasks.txt
markbiju16 Feb 19, 2022
f3bb3d2
Update build.gradle
markbiju16 Feb 19, 2022
53ed0bf
update A-Jar
markbiju16 Feb 19, 2022
dc7bd54
update Unmark
markbiju16 Feb 19, 2022
690237a
Update find
markbiju16 Feb 19, 2022
6cb9827
Update delete
markbiju16 Feb 19, 2022
cbc97e1
Add assertions
markbiju16 Feb 21, 2022
df4e00f
Update Ui.java
markbiju16 Feb 21, 2022
8ae349f
Merge branch 'branch-Level-10'
markbiju16 Feb 21, 2022
3e5b53a
Improve code quality
markbiju16 Feb 21, 2022
5dc99cf
Update Deadline.java
markbiju16 Feb 21, 2022
7b9e93d
Update Deadline.java
markbiju16 Feb 21, 2022
c13f1a0
Merge branch 'master' into branch-A-Assertions
markbiju Feb 21, 2022
134e81c
Merge pull request #2 from markbiju/branch-A-Assertions
markbiju Feb 21, 2022
7cab92e
Merge branch 'master' into branch-A-CodeQuality
markbiju Feb 21, 2022
be9a892
Merge pull request #3 from markbiju/branch-A-CodeQuality
markbiju Feb 21, 2022
d93a64d
Update deadline saving
markbiju16 Feb 21, 2022
84784f9
Merge branch 'master' of https://github.com/markbiju/ip
markbiju16 Feb 21, 2022
ad26dcd
Update deadline saving
markbiju16 Feb 21, 2022
9124b44
BCD-Extension
markbiju16 Feb 21, 2022
0613f16
Update README.md
markbiju16 Feb 21, 2022
354d8b1
Ui.png
markbiju16 Feb 21, 2022
aacf706
Update README.md
markbiju16 Feb 21, 2022
6deb38d
Update README.md
markbiju16 Feb 21, 2022
0411ea5
Update README.md
markbiju16 Feb 21, 2022
046ca8f
Update SnoozeCommand.java
markbiju16 Feb 21, 2022
0cf6b0c
Update README.md
markbiju Feb 22, 2022
dd9d9a3
Update Parser.java
markbiju16 Feb 24, 2022
d84593a
Update Parser.java
markbiju16 Feb 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Level-10
markbiju16 committed Feb 19, 2022
commit e11f89b6a5e177c431970a5791c4de4167ba9453
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -44,3 +44,24 @@ checkstyle {
run{
standardInput = System.in
}

repositories {
mavenCentral()
}

dependencies {
String javaFxVersion = '11'

implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
}
3 changes: 3 additions & 0 deletions data/tasks.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
T | 0 | eat chicken |
T | 0 | chicken
T | 0 | eat chicken
D | 0 | pray to god to thank him | 01 Dec 2022 1800
2 changes: 1 addition & 1 deletion src/main/java/duke/Command.java
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ public abstract class Command {
* @param ui User interface
* @throws DukeException when an error occurs
*/
public abstract void execute(Storage storage, TaskList tasks, Ui ui) throws DukeException;
public abstract String execute(Storage storage, TaskList tasks, Ui ui) throws DukeException;

/**
* Indicative of whether program should continue running
4 changes: 2 additions & 2 deletions src/main/java/duke/DeadlineCommand.java
Original file line number Diff line number Diff line change
@@ -24,9 +24,9 @@ public DeadlineCommand(String description, LocalDate by, String time) {
* @param tasks list of tasks
* @param ui User interface
*/
public void execute(Storage storage, TaskList tasks, Ui ui) {
public String execute(Storage storage, TaskList tasks, Ui ui) {
tasks.add(deadline);
ui.showDeadline(this.deadline, tasks);
return ui.showDeadline(this.deadline, tasks);
}

/**
4 changes: 2 additions & 2 deletions src/main/java/duke/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@ public DeleteCommand(int number) {
* @param tasks list of tasks
* @param ui User interface
*/
public void execute(Storage storage, TaskList tasks, Ui ui) {
ui.showDelete(tasks.get(number - 1), tasks);
public String execute(Storage storage, TaskList tasks, Ui ui) {
tasks.delete(number);
return ui.showDelete(tasks.get(number - 1), tasks);
}

/**
61 changes: 61 additions & 0 deletions src/main/java/duke/DialogBox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package duke;


import java.io.IOException;
import java.util.Collections;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;

/**
* An example of a custom control using FXML.
* This control represents a dialog box consisting of an ImageView to represent the speaker's face and a label
* containing text from the speaker.
*/
public class DialogBox extends HBox {
@FXML
private Label dialog;
@FXML
private ImageView displayPicture;

private DialogBox(String text, Image img) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml"));
fxmlLoader.setController(this);
fxmlLoader.setRoot(this);
fxmlLoader.load();
} catch (IOException e) {
e.printStackTrace();
}

dialog.setText(text);
displayPicture.setImage(img);
}

/**
* Flips the dialog box such that the ImageView is on the left and text on the right.
*/
private void flip() {
ObservableList<Node> tmp = FXCollections.observableArrayList(this.getChildren());
Collections.reverse(tmp);
getChildren().setAll(tmp);
setAlignment(Pos.TOP_LEFT);
}

public static DialogBox getUserDialog(String text, Image img) {
return new DialogBox(text, img);
}

public static DialogBox getDukeDialog(String text, Image img) {
var db = new DialogBox(text, img);
db.flip();
return db;
}}
31 changes: 6 additions & 25 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -24,32 +24,13 @@ public Duke(String filePath) {
}
}

/**
* Runs duke program
*/
public void run() {
ui.showWelcome();
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
ui.showLine(); // show the divider line ("_______")
Command c = Parser.parse(fullCommand);
c.execute(storage, tasks, ui);
isExit = c.isExit();
} catch (DukeException e) {
ui.showError(e.getMessage());
} finally {
ui.showLine();
}
public String getResponse(String input) {
try {
Command command = Parser.parse(input);
return command.execute(storage, tasks, ui);
} catch (DukeException e) {
return e.getMessage();
}
}

/**
* Main method
* @param args command line arguments
*/
public static void main(String[] args) {
new Duke("data/tasks.txt").run();
}
}
4 changes: 2 additions & 2 deletions src/main/java/duke/EventCommand.java
Original file line number Diff line number Diff line change
@@ -21,9 +21,9 @@ public EventCommand(String description, String at) {
* @param tasks list of tasks
* @param ui User interface
*/
public void execute(Storage storage, TaskList tasks, Ui ui) {
public String execute(Storage storage, TaskList tasks, Ui ui) {
tasks.add(event);
ui.showEvent(this.event, tasks);
return ui.showEvent(this.event, tasks);
}

/**
4 changes: 2 additions & 2 deletions src/main/java/duke/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ public class ExitCommand extends Command {
* @param ui User interface
*/
@Override
public void execute(Storage storage, TaskList tasks, Ui ui) throws DukeException {
ui.showExit(storage, tasks);
public String execute(Storage storage, TaskList tasks, Ui ui) throws DukeException {
return ui.showExit(storage, tasks);
}

/**
4 changes: 2 additions & 2 deletions src/main/java/duke/FindCommand.java
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ public FindCommand (String word) {
this.word = word;
}

public void execute(Storage storage, TaskList tasks, Ui ui) {
public String execute(Storage storage, TaskList tasks, Ui ui) {
TaskList matchingTasks = tasks.find(word);
ui.showFound(matchingTasks);
return ui.showFound(matchingTasks);
}

public boolean isExit() {
12 changes: 12 additions & 0 deletions src/main/java/duke/Launcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package duke;

import javafx.application.Application;

/**
* A launcher class to workaround classpath issues.
*/
public class Launcher {
public static void main(String[] args) {
Application.launch(Main.class, args);
}
}
4 changes: 2 additions & 2 deletions src/main/java/duke/ListCommand.java
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ public class ListCommand extends Command {
* @param tasks list of tasks
* @param ui User interface
*/
public void execute(Storage storage, TaskList tasks, Ui ui) {
ui.showTasks(tasks);
public String execute(Storage storage, TaskList tasks, Ui ui) {
return ui.showTasks(tasks);
}

/**
32 changes: 32 additions & 0 deletions src/main/java/duke/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package duke;

import java.io.IOException;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
* A GUI for Duke using FXML.
*/
public class Main extends Application {

private Duke duke = new Duke("data/tasks.txt");

@Override
public void start(Stage stage) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml"));
AnchorPane ap = fxmlLoader.load();
Scene scene = new Scene(ap);
stage.setScene(scene);
fxmlLoader.<MainWindow>getController().setDuke(duke);
stage.setTitle("I'm Adam!");
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
}
56 changes: 56 additions & 0 deletions src/main/java/duke/MainWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package duke;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
/**
* Controller for MainWindow. Provides the layout for the other controls.
*/
public class MainWindow extends AnchorPane {
@FXML
private ScrollPane scrollPane;
@FXML
private VBox dialogContainer;
@FXML
private TextField userInput;
@FXML
private Button sendButton;

private Duke duke;

private Image userImage = new Image(this.getClass().getResourceAsStream("/images/Mark.png"));
private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/Adam.png"));

/**
* shows welcome screen
*/
@FXML
public void initialize() {
scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
String welcome = "Hey bud! I'm Adam\nTo what do I owe this pleasure, buddy?";
dialogContainer.getChildren().addAll(DialogBox.getDukeDialog(welcome, dukeImage));

}

public void setDuke(Duke d) {
duke = d;
}

/**
* Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to
* the dialog container. Clears the user input after processing.
*/
@FXML
private void handleUserInput() {
String input = userInput.getText();
String response = duke.getResponse(input);
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getDukeDialog(response, dukeImage)
);
userInput.clear();
}
}
4 changes: 2 additions & 2 deletions src/main/java/duke/MarkCommand.java
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@ public MarkCommand(int number) {
* @param tasks list of tasks
* @param ui User interface
*/
public void execute(Storage storage, TaskList tasks, Ui ui) {
public String execute(Storage storage, TaskList tasks, Ui ui) {
tasks.mark(number);
ui.showMark(tasks.get(number));
return ui.showMark(tasks.get(number));
}

/**
4 changes: 2 additions & 2 deletions src/main/java/duke/TodoCommand.java
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@ public TodoCommand(String description) {
* @param tasks list of tasks
* @param ui User interface
*/
public void execute(Storage storage, TaskList tasks, Ui ui) {
public String execute(Storage storage, TaskList tasks, Ui ui) {
tasks.add(todo);
ui.showTodo(this.todo, tasks);
return ui.showTodo(this.todo, tasks);
}

/**
Loading