Skip to content

Commit

Permalink
Refactor Duke to Socrates
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelim01 committed Oct 1, 2023
1 parent 5a1e742 commit 43f4fe5
Show file tree
Hide file tree
Showing 44 changed files with 244 additions and 246 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ test {
}

application {
mainClass.set("duke.Launcher")
mainClass.set("socrates.Launcher")
}

checkstyle {
toolVersion = '10.2'
}

shadowJar {
archiveBaseName = "duke"
archiveBaseName = "socrates"
archiveClassifier = null
dependsOn("distZip", "distTar")
}
Expand Down
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# User Guide

Duke is a **desktop app for managing tasks, optimized for use via a Command Line Interface** (CLI) while still having the benefits of a Graphical User Interface (GUI).
SoCrates is a **desktop app for managing tasks, optimized for use via a Command Line Interface** (CLI) while still having the benefits of a Graphical User Interface (GUI).

- [Quick start](#quick-start)
- [Features](#features)
Expand All @@ -20,9 +20,9 @@ Duke is a **desktop app for managing tasks, optimized for use via a Command Line
## Quick start

1. Ensure you have Java `11` or above installed in your computer.
2. Download the latest `duke.jar` from [here](https://github.com/samuelim01/ip/releases).
2. Download the latest `socrates.jar` from [here](https://github.com/samuelim01/ip/releases).
3. Copy the file to the folder you want to use as the _home folder_ for your chatbot.
4. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar duke.jar` commmand to run the application.
4. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar socrates.jar` commmand to run the application.
5. Type the command in the command box and press Enter to execute it. You may refer to the [Features](#features) below for the details of each command.


Expand Down
Binary file modified docs/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 0 additions & 16 deletions src/main/java/duke/data/exception/DukeException.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package duke;
package socrates;

import javafx.application.Application;

/**
* Represents a launcher for the Duke chatbot.
* Represents a launcher for the SoCrates chatbot.
*/
public class Launcher {

/**
* Launches the Duke chatbot application.
* Launches the SoCrates chatbot application.
*
* @param args
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package duke;
package socrates;

import java.io.IOException;

import duke.gui.MainWindow;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import socrates.gui.MainWindow;

/**
* Represents a GUI for Duke
* Represents a GUI for Socrates
*/
public class Main extends Application {

private final Duke duke = new Duke();
private final Socrates socrates = new Socrates();

@Override
public void start(Stage stage) {
Expand All @@ -23,10 +23,10 @@ public void start(Stage stage) {
AnchorPane ap = fxmlLoader.load();
Scene scene = new Scene(ap);
stage.setScene(scene);
fxmlLoader.<MainWindow>getController().setDuke(duke);
fxmlLoader.<MainWindow>getController().setSocrates(socrates);
stage.show();

stage.setTitle("Duke");
stage.setTitle("SoCrates");
stage.setResizable(false);
} catch (IOException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package duke;
package socrates;

import duke.command.Command;
import duke.command.CommandResult;
import duke.data.exception.DukeException;
import duke.data.exception.StorageLoadException;
import duke.data.task.TaskList;
import duke.parser.Parser;
import duke.storage.Storage;
import socrates.command.Command;
import socrates.command.CommandResult;
import socrates.data.exception.SocratesException;
import socrates.data.exception.StorageLoadException;
import socrates.data.task.TaskList;
import socrates.parser.Parser;
import socrates.storage.Storage;

/**
* Represents a chatbot. This initializes the chatbot application and is
* the entry point to interaction with the user.
*/
public class Duke {
public class Socrates {

public static final String WELCOME_MESSAGE = "Hello! I'm Duke. What would you like to do today?";
public static final String WELCOME_MESSAGE = "Hello! I'm SoCrates. What would you like to do today?";

/** The file path where the data of the chatbot is stored */
private static final String FILE_PATH = "data/tasks.txt";
Expand All @@ -28,7 +28,7 @@ public class Duke {
* Loads up the data from the storage file, and shows the welcome message.
*
*/
public Duke() {
public Socrates() {
storage = new Storage(FILE_PATH);
try {
tasks = new TaskList(storage.load());
Expand All @@ -46,7 +46,7 @@ public Duke() {
* @param input The input by the user.
* @return The response by the chatbot.
*/
public CommandResult getResponse(String input) throws DukeException {
public CommandResult getResponse(String input) throws SocratesException {
Command command = Parser.parse(input);
return command.execute(tasks, storage);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package duke.command;
package socrates.command;

import java.time.LocalDate;
import java.time.format.DateTimeParseException;

import duke.data.exception.DukeException;
import duke.data.exception.InvalidDateException;
import duke.data.task.Deadline;
import socrates.data.exception.InvalidDateException;
import socrates.data.exception.SocratesException;
import socrates.data.task.Deadline;

/**
* Represents a command to add a new deadline to the list of tasks.
Expand All @@ -18,13 +18,13 @@ public class AddDeadlineCommand extends AddTaskCommand {

/**
* Returns an instance of {@code AddDeadlineCommand} with the given description, by dates.
* If there is an error in parsing the date, throws a {@code DukeException}.
* If there is an error in parsing the date, throws a {@code SocratesException}.
*
* @param description The description of the deadline.
* @param by The due date of the event in \'yyyy-mm-dd\' format.
* @throws DukeException If there is an error in parsing the by field as a date.
* @throws SocratesException If there is an error in parsing the by field as a date.
*/
public AddDeadlineCommand(String description, String by) throws DukeException {
public AddDeadlineCommand(String description, String by) throws SocratesException {
try {
this.toAdd = new Deadline(description, LocalDate.parse(by));
} catch (DateTimeParseException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package duke.command;
package socrates.command;

import java.time.LocalDate;
import java.time.format.DateTimeParseException;

import duke.data.exception.DukeException;
import duke.data.exception.InvalidDateException;
import duke.data.task.Event;
import socrates.data.exception.InvalidDateException;
import socrates.data.exception.SocratesException;
import socrates.data.task.Event;

/**
* Represents a command to add a new event to the list of tasks.
Expand All @@ -17,14 +17,14 @@ public class AddEventCommand extends AddTaskCommand {

/**
* Returns an instance of {@code AddEventCommand} with the given description, from and to dates.
* If there is an error in parsing the date, throws a {@code DukeException}.
* If there is an error in parsing the date, throws a {@code SocratesException}.
*
* @param description The description of the event.
* @param from The start date of the event in \'yyyy-mm-dd\' format.
* @param to The end date of the event in \'yyyy-mm-dd\' format.
* @throws DukeException If there is an error in parsing from and to as dates.
* @throws SocratesException If there is an error in parsing from and to as dates.
*/
public AddEventCommand(String description, String from, String to) throws DukeException {
public AddEventCommand(String description, String from, String to) throws SocratesException {
try {
this.toAdd = new Event(description, LocalDate.parse(from), LocalDate.parse(to));
} catch (DateTimeParseException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package duke.command;
package socrates.command;

import duke.data.exception.DukeException;
import duke.data.task.Task;
import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.exception.SocratesException;
import socrates.data.task.Task;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command to add a new task.
Expand All @@ -20,7 +20,7 @@ protected String getCommandResponse(TaskList tasks) {
}

@Override
public CommandResult execute(TaskList tasks, Storage storage) throws DukeException {
public CommandResult execute(TaskList tasks, Storage storage) throws SocratesException {
tasks.add(toAdd);
storage.save(tasks);
return new CommandResult(getCommandResponse(tasks));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package duke.command;
package socrates.command;

import duke.data.task.Todo;
import socrates.data.task.Todo;

/**
* Represents a command to add a new todo to the list of tasks.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package duke.command;
package socrates.command;

import duke.data.exception.DukeException;
import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.exception.SocratesException;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command to clear the task list.
Expand All @@ -14,7 +14,7 @@ public class ClearCommand extends Command {
private static final String COMMAND_RESPONSE = "Got it. I've cleared all tasks.";

@Override
public CommandResult execute(TaskList tasks, Storage storage) throws DukeException {
public CommandResult execute(TaskList tasks, Storage storage) throws SocratesException {
tasks.clear();
storage.save(tasks);
return new CommandResult(COMMAND_RESPONSE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package duke.command;
package socrates.command;

import duke.data.exception.DukeException;
import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.exception.SocratesException;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command given by the user.
Expand All @@ -17,8 +17,8 @@ public abstract class Command {
* @param tasks The list of tasks in the application.
* @param storage The storage file of the application.
* @return The response by the bot.
* @throws DukeException If there is any issue with the constructed command.
* @throws SocratesException If there is any issue with the constructed command.
*/
public abstract CommandResult execute(TaskList tasks, Storage storage) throws DukeException;
public abstract CommandResult execute(TaskList tasks, Storage storage) throws SocratesException;

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package duke.command;
package socrates.command;

//@@author samuelim01-reused
// Reused from Addressbook Level 3 with minor modifications.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package duke.command;
package socrates.command;

import duke.data.exception.DukeException;
import duke.data.task.Task;
import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.exception.SocratesException;
import socrates.data.task.Task;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command to delete the specified task.
Expand All @@ -19,7 +19,7 @@ public DeleteCommand(String taskIndex) {
}

@Override
public CommandResult execute(TaskList tasks, Storage storage) throws DukeException {
public CommandResult execute(TaskList tasks, Storage storage) throws SocratesException {
Task task = tasks.remove(taskIndex);
storage.save(tasks);
return new CommandResult(COMMAND_RESPONSE_SUCCESS + task);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.command;
package socrates.command;

import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command to exit the chatbot application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.command;
package socrates.command;

import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command to find tasks that match the keyword provided.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.command;
package socrates.command;

import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command to list all existing commands
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.command;
package socrates.command;

import duke.data.task.TaskList;
import duke.storage.Storage;
import socrates.data.task.TaskList;
import socrates.storage.Storage;

/**
* Represents a command to list all existing tasks.
Expand Down
Loading

0 comments on commit 43f4fe5

Please sign in to comment.