Skip to content

Commit

Permalink
Change name of app
Browse files Browse the repository at this point in the history
  • Loading branch information
tandeshao committed Feb 13, 2022
1 parent 21e5b42 commit 9bca5c4
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 118 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This is a greenfield Java project for CS2103T Software Engineering.
> Good programmers write code that humans can understand.”
> -Martin Fowler.
## What is Duke?
## What is Nexus?
***
Duke is a basic Todo List with a built-in interface for users to interact with.
Nexus is a basic Todo List with a built-in interface for users to interact with.

**Features include:**
- [x] ~~Adding new Tasks~~ **IMPROVED! Able to add specific tasks such as: Todo, Deadlines and Events!**
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This is a greenfield Java project for CS2103T Software Engineering.
> Good programmers write code that humans can understand.”
> -Martin Fowler.
## What is Duke?
## What is Nexus?
***
Duke is a basic Todo List with a built-in interface for users to interact with.
Nexus is a basic Todo List with a built-in interface for users to interact with.

**Features include:**
- [x] ~~Adding new Tasks~~ **IMPROVED! Able to add specific tasks such as: Todo, Deadlines and Events!**
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private DialogBox(String text, Image img) {
* Flips the dialog box such that the ImageView is on the left and text on the right.
*/
private void flip() {
//logic for flipping the dialog box in Duke interface.
//logic for flipping the dialog box in Nexus interface.
ObservableList<Node> tmp = FXCollections.observableArrayList(this.getChildren());
Collections.reverse(tmp);
getChildren().setAll(tmp);
Expand All @@ -64,12 +64,12 @@ public static DialogBox getUserDialog(String text, Image img) {
}

/**
* Gets Duke dialog.
* @param text Text that is replied by Duke.
* @param img Image of Duke.
* @return Duke dialog.
* Gets Nexus dialog.
* @param text Text that is replied by Nexus.
* @param img Image of Nexus.
* @return Nexus dialog.
*/
public static DialogBox getDukeDialog(String text, Image img) {
public static DialogBox getNexusDialog(String text, Image img) {
var db = new DialogBox(text, img);
db.flip();
return db;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Launcher {
* @param args Command line argument for main.
*/
public static void main(String[] args) {
//Launches the duke application with a GUI.
//Launches the Nexus application with a GUI.
Application.launch(Main.class, args);
}
}
2 changes: 1 addition & 1 deletion src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: Duke
Main-Class: Nexus

10 changes: 5 additions & 5 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import javafx.stage.Stage;

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

private final Duke duke = new Duke();
private final Nexus nexus = new Nexus();

/**
* Starts the interface.
Expand All @@ -24,12 +24,12 @@ public void start(Stage stage) {
AnchorPane ap = fxmlLoader.load();
Scene scene = new Scene(ap);

stage.setTitle("Dodo");
stage.setTitle("Nexus");
// Set the scene of the interface.
stage.setScene(scene);

// Set duke into the interface.
fxmlLoader.<MainWindow>getController().setDuke(duke);
// Set Nexus into the interface.
fxmlLoader.<MainWindow>getController().setNexus(nexus);

// show the interface onto user's screen.
stage.show();
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ public class MainWindow extends AnchorPane {
@FXML
private TextField userInput;

private Duke duke;
private Nexus nexus;

private final Image userImage;
private final Image dukeImage;
private final Image nexusImage;

/**
* Constructs MainWindow.
*/
public MainWindow() {
InputStream daUserPath = this.getClass().getResourceAsStream("/images/DaUser.png");
InputStream daDukePath = this.getClass().getResourceAsStream("/images/DaDuke.png");
InputStream daNexusPath = this.getClass().getResourceAsStream("/images/DaNexus.png");

//Checks if both userPath and dukePath is not null using assertions.
//Checks if both userPath and nexusPath is not null using assertions.
assert daUserPath != null : "daUser path not suppose to be null!";
assert daDukePath != null : "daDuke path not suppose to be null!";
assert daNexusPath != null : "daNexus path not suppose to be null!";

// Creates image based on the path provided.
userImage = new Image(daUserPath);
dukeImage = new Image(daDukePath);
nexusImage = new Image(daNexusPath);
}

/**
Expand All @@ -49,28 +49,28 @@ public void initialize() {
}

/**
* Sets the duke instance in the dialog container.
* @param d duke instance.
* Sets the Nexus instance in the dialog container.
* @param d Nexus instance.
*/
public void setDuke(Duke d) {
duke = d;
public void setNexus(Nexus d) {
nexus = d;
dialogContainer.getChildren().addAll(
DialogBox.getDukeDialog(d.initUi(), dukeImage)
DialogBox.getNexusDialog(d.initUi(), nexusImage)
);
}

/**
* Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to
* Creates two dialog boxes, one echoing user input and the other containing Nexus's reply and then appends them to
* the dialog container. Clears the user input after processing.
*/
@FXML
private void handleUserInput() {
//handle user input and places userImage and dukeImage in the scene.
//handle user input and places userImage and nexusImage in the scene.
String input = userInput.getText();
String response = duke.getResponse(input);
String response = nexus.getResponse(input);
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getDukeDialog(response, dukeImage)
DialogBox.getNexusDialog(response, nexusImage)
);
userInput.clear();

Expand Down
20 changes: 8 additions & 12 deletions src/main/java/Duke.java → src/main/java/Nexus.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
import component.Ui;

/**
* A class that encapsulates the logic of Duke - A todo list program
* A class that encapsulates Nexus the logic of - A todo list program
* that helps user keep track of tasks.
*/
public class Duke {
/**
* Default path name to retrieve the data from previous instance of duke.
*/
private static final String DEFAULT_STORAGE_PATH_NAME = "data/duke.txt";
public class Nexus {
/**
* {@link Storage}
*/
Expand All @@ -26,28 +22,28 @@ public class Duke {
private final Ui ui;

/**
* Constructs Duke
* Constructs Nexus
*/
public Duke() {
public Nexus() {
this.ui = new Ui();
this.storage = new Storage(DEFAULT_STORAGE_PATH_NAME);
this.storage = new Storage();
this.tasks = new TaskList(storage.load());
}

/**
* Initialises the Duke Ui.
* Initialises the Nexus Ui.
*/
public String initUi() {
return ui.initUi();
}

/**
* Gets the response from duke with the userInput.
* Gets the response from Nexus with the userInput.
* @param userInput User input in the form of a string.
* @return String showing the user input.
*/
public String getResponse(String userInput) {
//runs the ui to retrieve the output based on userInput.
return ui.generateDukeReply(tasks, storage, userInput);
return ui.generateNexusReply(tasks, storage, userInput);
}
}
56 changes: 28 additions & 28 deletions src/main/java/component/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


/**
* A class that belongs to the DukeComponent Package.
* This class encapsulates the possible user commands from Duke.
* A class that belongs to the component package.
* This class encapsulates the possible user commands from Nexus.
*/
public class Command {
private final String userInput;
Expand All @@ -20,16 +20,16 @@ public class Command {
/**
* Constructs Command class.
* @param userInput User input as a type String.
* @param t Provides access to TaskList for some manipulation in the Duke program.
* @param t Provides access to TaskList for some manipulation in the Nexus program.
*/
public Command(String userInput, TaskList t) {
this.userInput = userInput;
this.tasks = t;
}

/**
* Runs command to return duke reply.
* @return A string representing what Duke replied.
* Runs command to return Nexus reply.
* @return A string representing what Nexus replied.
*/
public String runCommand() {
String[] wordSplit = userInput.split(" ");
Expand All @@ -42,7 +42,7 @@ public String runCommand() {

switch (action) {
case "help":
// Shows the commands that are available in duke.
// Shows the commands that are available in Nexus.
return printCommandsAvailable();
case "list":
return printList();
Expand All @@ -66,79 +66,79 @@ public String runCommand() {
}

/**
* Prints commands that are available n Duke.
* @return A string representing what Duke replied.
* Prints commands that are available n Nexus.
* @return A string representing what Nexus replied.
*/
private String printCommandsAvailable() {
String openingStatement = "Here are some of the available commands in Duke: \n";
String openingStatement = "Here are some of the available commands in Nexus: \n";
String commands = "1. list\n2. mark"
+ "\n3. unmark\n4. todo\n 5.deadline\n 6. event\n "
+ "7. event\n 8. delete\n 9. find\n 10. bye";
+ "\n3. unmark\n4. todo\n5.deadline\n6. event\n"
+ "7. delete\n8. find\n9. bye";
return openingStatement + commands;
}

/**
* Finds Task that matches that description from the TaskList.
* @param description Description to be used for matching.
* @return A string representing what Duke replied.
* @return A string representing what Nexus replied.
*/
private String find(String description) {
String dukeReply = "Here are the matching task in your list: ";
String nexusReply = "Here are the matching task in your list: ";
String resultOfFind = tasks.findDescription(description);
return dukeReply + "\n" + resultOfFind;
return nexusReply + "\n" + resultOfFind;
}


/**
* Deletes the task in the TaskList.
* @param index 0-based index for deletion of Task in the TaskList.
* @return A string representing what Duke replied.
* @return A string representing what Nexus replied.
*/
private String deleteTask(int index) {
String dukeReply = "Noted. I've removed this task:" + "\n" + tasks.remove(index);
String nexusReply = "Noted. I've removed this task:" + "\n" + tasks.remove(index);
String additionalStatement = String.format("Now you have %d tasks in the list.", tasks.listSize());
return dukeReply + "\n" + additionalStatement;
return nexusReply + "\n" + additionalStatement;
}

/**
* Marks the task in the TaskList.
* @param index 0-based index for users to mark the Task in the TaskList.
* @return A string representing what Duke replied.
* @return A string representing what Nexus replied.
*/
private String mark(int index) {
String dukeReply = "Nice! I've marked this task as done:";
String nexusReply = "Nice! I've marked this task as done:";
Tasks retrievedTask = tasks.getTask(index);
retrievedTask.setMarked();
return dukeReply + "\n" + retrievedTask;
return nexusReply + "\n" + retrievedTask;
}

/**
* Un-marks the task in the TaskList.
* @param index 0-based index for users to unmark the task in the TaskList.
* @return A string representing what Duke replied.
* @return A string representing what Nexus replied.
*/
private String unmark(int index) {
String dukeReply = "OK, I've marked this task as not done yet:";
String nexusReply = "OK, I've marked this task as not done yet:";
Tasks retrievedTask = tasks.getTask(index);
retrievedTask.setUnmarked();
return dukeReply + "\n" + retrievedTask;
return nexusReply + "\n" + retrievedTask;
}

/**
* Adds task to the TaskList.
* @param newTask Task to be added.
* @return A string representing what Duke replied.
* @return A string representing what Nexus replied.
*/
private String addTask(Tasks newTask) {
tasks.addTask(newTask);
String dukeReply = "Got it. I've added this task:" + "\n" + " " + newTask;
String nexusReply = "Got it. I've added this task:" + "\n" + " " + newTask;
String amountOfTaskInList = String.format("Now you have %d tasks in the list.", tasks.listSize());
return dukeReply + "\n" + amountOfTaskInList;
return nexusReply + "\n" + amountOfTaskInList;
}

/**
* Prints the TaskList in the Ui.
* @return A string representing what Duke replied.
* @return A string representing what Nexus replied.
*/
private String printList() {
StringBuilder result = new StringBuilder("Here are the tasks in your list:");
Expand All @@ -152,7 +152,7 @@ private String printList() {

/**
* Prints the bye Ui for the user.
* @return A string representing what Duke replied.
* @return A string representing what Nexus replied.
*/
private String sayBye() {
return "Bye. Hope to see you again soon!";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/component/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import exceptions.WrongInputException;

/**
* A class that belongs to the DukeComponent Package.
* This class encapsulates the Parser logic from users in Duke.
* A class that belongs to the component package.
* This class encapsulates the Parser logic from users in Nexus.
*/
public class Parser {
private final String input;
Expand Down Expand Up @@ -42,7 +42,7 @@ public String executeCommand(TaskList tasks) {
private void checkUserInput(String userInput) throws TaskException {
String[] wordsSplitByEmptySpace = userInput.split(" ");
String firstWord = wordsSplitByEmptySpace[0];
if (firstWord.equals("mark") || firstWord.equals("unmark")) {
if (firstWord.equals("mark") || firstWord.equals("unmark") || firstWord.equals("delete")) {
checkForWrongInputException(wordsSplitByEmptySpace);
}

Expand Down
Loading

0 comments on commit 9bca5c4

Please sign in to comment.