Skip to content

Commit

Permalink
Update coding standard
Browse files Browse the repository at this point in the history
Following Git conventions can help make it easier to understand and follow the codebase.

Any changes made will also be easy to understand.
  • Loading branch information
Darkarche3 committed Feb 9, 2024
1 parent 827b375 commit 5fb1769
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 40 deletions.
3 changes: 2 additions & 1 deletion src/main/java/area/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class Deadline extends Task {
* @param description
* @param by
*/
public Deadline(String description, String by) {
public Deadline(String description,
String by) {
super(description);
this.details = LocalDate.parse(by);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/area/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public void run() {
// instruction for the chatbot to follow
String instruction = "";
ui.greetUser();
boolean chatting = true;
boolean isChatting = true;
Parser parser = new Parser();
while (chatting) {
while (isChatting) {
instruction = sc.nextLine();
String command = parser.parseCommand(instruction);
try {
if (command.equals("bye")) {
storage.saveTasks();
// command to end chat with chatbot
ui.endChat();
chatting = false;
isChatting = false;
break;
} else if (command.equals("list")) {
ui.showList(tasks);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/area/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public class Event extends Task {
* @param from
* @param to
*/
public Event(String description, String from, String to) {
public Event(String description,
String from,
String to) {
super(description);
this.from = from;
this.to = to;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/area/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class Parser {

public Parser() {
public Parser(){
}

/**
Expand All @@ -11,7 +11,7 @@ public Parser() {
* @param instruction
* @return String
*/
public String parseCommand(String instruction) {
public String parseCommand(String instruction){
String[] sentence = instruction.split(" ", 2);
String command = sentence[0];
return command;
Expand All @@ -23,7 +23,7 @@ public String parseCommand(String instruction) {
* @param instruction
* @return
*/
public String parseDesription(String instruction) {
public String parseDesription(String instruction){
String[] sentence = instruction.split(" ", 2);
String description = sentence[1];
return description;
Expand All @@ -35,7 +35,7 @@ public String parseDesription(String instruction) {
* @param instruction
* @return String
*/
public String parseModify(String instruction) {
public String parseModify(String instruction){
String[] sentence = instruction.split(" ", 2);
if (sentence.length == 1) {
throw new IllegalArgumentException("Please enter an index.");
Expand All @@ -51,7 +51,7 @@ public String parseModify(String instruction) {
* @param instruction
* @return String
*/
public String parseTodo(String instruction) {
public String parseTodo(String instruction){
String[] sentence = instruction.split(" ", 2);
if (sentence.length == 1) {
throw new IllegalArgumentException("Your input is incomplete. Please add more details for " + instruction);
Expand All @@ -66,7 +66,7 @@ public String parseTodo(String instruction) {
* @param instruction
* @return String[]
*/
public String[] parseDeadline(String instruction) {
public String[] parseDeadline(String instruction){
String[] sentence = instruction.split(" ", 2);
if (sentence.length == 1) {
throw new IllegalArgumentException("Your input is incomplete. Please add more details for " + instruction);
Expand All @@ -83,7 +83,7 @@ public String[] parseDeadline(String instruction) {
* @param instruction
* @return String[]
*/
public String[] parseEvent(String instruction) {
public String[] parseEvent(String instruction){
String[] sentence = instruction.split(" ", 2);
if (sentence.length == 1) {
throw new IllegalArgumentException("Your input is incomplete. Please add more details for " + instruction);
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/area/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class Storage {
private ArrayList<String> instructions;

/**
* creates an object of type Storage
* Return an object of type Storage
*
* @param path
* @param tasks
*/
public Storage(String path, TaskList tasks) {
public Storage(String path, TaskList tasks){
this.filePath = path;
file = new File(path);
folder = new File("./data");
Expand All @@ -34,11 +34,11 @@ public Storage(String path, TaskList tasks) {
}

/**
* adds an instruction to a list of instructions
* Add an instruction to a list of instructions
*
* @param instruction
*/
public void addInstruction(String instruction) {
public void addInstruction(String instruction){
this.instructions.add(instruction);
}

Expand All @@ -57,11 +57,11 @@ public void createFile() {
}

/**
* get list of tasks
* Get list of tasks
*
* @return ArrayList<String>
*/
public static ArrayList<String> getTasks() {
public static ArrayList<String> getTasks(){
return taskList;
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public void loadTasks() {
}
}

public void saveTasks() {
public void saveTasks(){
try {
FileWriter writer = new FileWriter(filePath, true);
for (String instruction : this.instructions) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/area/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ public class Task {
*
* @param description
*/
public Task(String description) {
public Task(String description){
this.description = description;
this.isDone = false;
}

/**
* gets status of task.
* Get status of task.
*
* @return String
*/
public String getStatusIcon() {
public String getStatusIcon(){
return (isDone ? "X" : " "); // mark done task with X
}

/**
* gets description of task
* Get description of task
*
* @return String
*/
public String getDescription() {
public String getDescription(){
return this.description;
}

/**
* sets work as done
* Set work as done
*/
public void taskDone() {
public void taskDone(){
isDone = true;
}

/**
* sets work as undone
* Set work as undone
*/
public void taskUndone() {
public void taskUndone(){
isDone = false;
}

@Override
public String toString() {
public String toString(){
return "[" + this.getStatusIcon() + "] " + this.getDescription();
}
}
2 changes: 1 addition & 1 deletion src/main/java/area/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void addTask(String instruction) {
*
* @param instruction
*/
public void modifyTask(String instruction) {
public void modifyTask(String instruction){
String command = parser.parseCommand(instruction);
if (command.equals("mark")) {
// marks a task as done
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/area/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Todo extends Task {
*
* @param description
*/
public Todo(String description) {
public Todo(String description){
super(description);
}

Expand All @@ -17,7 +17,7 @@ public Todo(String description) {
* @return String
*/
@Override
public String toString() {
public String toString(){
return "[T]" + super.toString();
}
}
10 changes: 5 additions & 5 deletions src/main/java/area/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void taskUndone(int num, TaskList tasks) {
* @param deletedTask
* @param tasks
*/
public void deleteTask(Task deletedTask, TaskList tasks) {
public void deleteTask(Task deletedTask, TaskList tasks){
System.out.println("Noted. I've removed this task:\n" + deletedTask.toString() + "\n" + "Now you have "
+ tasks.getNumberOfTasks() + " tasks in the list.\n");
}
Expand All @@ -59,22 +59,22 @@ public void deleteTask(Task deletedTask, TaskList tasks) {
*
* @param tasks
*/
public void showList(TaskList tasks) {
public void showList(TaskList tasks){
for (int i = 0; i < tasks.getNumberOfTasks(); i++) {
System.out.println(i + 1 + "." + tasks.getTaskList().get(i).toString());
}
System.out.print("\n");
}

public void endChat() {
public void endChat(){
System.out.println("Bye. Hope to see you again soon!");
}

/**
*
* @param instruction
*/
public void instructionError(String instruction) {
public void instructionError(String instruction){
DukeException error = new DukeException(instruction);
System.out.println(error.toString());
}
Expand All @@ -83,7 +83,7 @@ public void instructionError(String instruction) {
*
* @throws Exception
*/
public void showLoadingError() throws Exception {
public void showLoadingError() throws Exception{
System.out.println("Loading Error: Your file does not exist");
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/area/DeadlineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class DeadlineTest {
@Test
public void todoStringsuccess(){
public void toString_returnDeadline_stringReturnedsuccess(){
Deadline deadline = new Deadline("CS2103T" , "2021-12-31");
assertEquals("[D][ ] CS2103T (by: Dec 31 2021)", deadline.toString());
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/area/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class ParserTest {
@Test
public void parseCommandSuccess(){
public void parseCommand_addTasks_success(){
Parser parser = new Parser();
assertEquals("todo", parser.parseCommand("todo book"));
assertEquals("deadline", parser.parseCommand("deadline assignment /by 2021-12-31"));
Expand All @@ -14,7 +14,7 @@ public void parseCommandSuccess(){
}

@Test
public void parseDescriptionSuccess(){
public void parseDescription_addDescriptions_success(){
Parser parser = new Parser();
assertEquals("book", parser.parseDesription("todo book"));
assertEquals("2", parser.parseDesription("unmark 2"));
Expand Down

0 comments on commit 5fb1769

Please sign in to comment.