Skip to content

Commit 7040f64

Browse files
committed
Merge branch 'branch-A-JavaDoc'
2 parents 918d17d + b03c728 commit 7040f64

18 files changed

Lines changed: 225 additions & 9 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ bin/
1616
/text-ui-test/ACTUAL.txt
1717
text-ui-test/EXPECTED-UNIX.TXT
1818
/data/*
19+
/src/main/java/META-INF/

src/main/java/duke/Duke.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77
import java.io.IOException;
88
import java.time.format.DateTimeParseException;
99

10+
/**
11+
* Represents a task manager
12+
*/
1013
public class Duke {
1114
private Storage storage;
1215
private TaskList tasks;
1316
private Ui ui;
1417

18+
/**
19+
* Class constructor with specified file path.
20+
*
21+
* @param filePath The path to load and save from
22+
*/
1523
public Duke(String filePath) {
1624
ui = new Ui();
1725
storage = new Storage(filePath);
@@ -25,7 +33,9 @@ public Duke(String filePath) {
2533
tasks = new TaskList();
2634
}
2735
}
28-
36+
/**
37+
* Runs the duke programme.
38+
*/
2939
public void run() {
3040
Command c = new WelcomeCommand();
3141
c.execute(tasks, ui, storage);

src/main/java/duke/Parser.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@
1818
import java.time.LocalDate;
1919
import java.time.format.DateTimeParseException;
2020

21+
/**
22+
* Parser for Duke commands
23+
*/
2124
public class Parser {
25+
26+
/**
27+
* Parses a string input to the relevent command instruction.
28+
*
29+
* @param input The String to be parsed
30+
* @return Command to be executed
31+
* @throws DukeException
32+
*/
2233
public static Command parse(String input) throws DukeException{
2334
switch (input) {
2435
case "bye":

src/main/java/duke/Storage.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,28 @@
1515
import java.time.LocalDate;
1616
import java.time.format.DateTimeParseException;
1717

18+
/**
19+
* Storage for Duke
20+
*/
1821
public class Storage {
1922
private String filePath;
2023

24+
/**
25+
* Construction with specified file path
26+
*
27+
* @param filePath the file path to load and save from
28+
*/
2129
public Storage(String filePath) {
2230
this.filePath = filePath;
2331
}
2432

33+
/**
34+
* Loads task list from the file path given during initialisation
35+
*
36+
* @return List of saved tasks
37+
* @throws IOException
38+
* @throws DateTimeParseException
39+
*/
2540
public TaskList load() throws IOException, DateTimeParseException {
2641
int lastDelimiterIndex = this.filePath.lastIndexOf("/");
2742
if (lastDelimiterIndex < 0) {
@@ -70,6 +85,12 @@ public TaskList load() throws IOException, DateTimeParseException {
7085
return memList;
7186
}
7287

88+
/**
89+
* Stores task list into file path specified during initialisation
90+
*
91+
* @param tasks Task list to be saved
92+
* @throws IOException
93+
*/
7394
public void store(TaskList tasks) throws IOException {
7495
FileWriter fw = new FileWriter(this.filePath);
7596

src/main/java/duke/Ui.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,72 @@
22

33
import java.util.Scanner;
44

5+
/**
6+
* Interface that handles user inputs and prints programme outputs
7+
*/
58
public class Ui {
69
private Scanner sc;
710

11+
/**
12+
* Constructor
13+
*/
814
public Ui() {
915
this.sc = new Scanner(System.in);
1016
}
1117

18+
/**
19+
* Reads one line of the user input
20+
* @return
21+
*/
1222
public String readCommand() {
1323
return this.sc.nextLine().strip();
1424
}
1525

26+
/**
27+
* Closes the interface.
28+
* Once closed, the Ui will no longer read user inputs
29+
*/
1630
public void close() {
1731
this.sc.close();
1832
}
1933

20-
// format for greeting, echo and exit
34+
/**
35+
* Prints a message in the Duke format
36+
* @param message Message to be printed
37+
*/
2138
public void printMessage(String message) {
2239
String newMessage = message.replaceAll("\n", "\n ");
2340
System.out.println(" ____________________________________________________________\n\n" + " " + newMessage
2441
+ "\n" + " ____________________________________________________________\n");
2542
}
2643

44+
/**
45+
* Prints welcome message
46+
*/
2747
public void showWelcome() {
2848
String welcomeMessage = "Hello! I'm Duke\nWhat can I do for you?";
2949
printMessage(welcomeMessage);
3050
}
3151

52+
/**
53+
* Prints error for loading save file
54+
*/
3255
public void showLoadingError() {
3356
String loadingErrMessage = "OOPS!!! Was unable to load from save\nStarting a new task list...";
3457
printMessage(loadingErrMessage);
3558
}
3659

60+
/**
61+
* Shows error for reading save file
62+
*/
3763
public void showReadingError() {
3864
String loadingErrMessage = "OOPS!!! Was unable to parse save file\nStarting a new task list...";
3965
printMessage(loadingErrMessage);
4066
}
4167

68+
/**
69+
* Shows goodbye message
70+
*/
4271
public void showGoodbye() {
4372
String goodbyeMessage = "Bye. Hope to see you again soon!";
4473
printMessage(goodbyeMessage);

src/main/java/duke/command/AddCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66
import duke.task.Task;
77
import duke.task.TaskList;
88

9+
/**
10+
* Represents a command telling duke to add a task to its task list
11+
*/
912
public class AddCommand implements Command {
1013
Task taskToAdd;
1114

15+
/**
16+
* Constructor
17+
*
18+
* @param task Task to be added
19+
*/
1220
public AddCommand(Task task) {
1321
this.taskToAdd = task;
1422
}

src/main/java/duke/command/CheckCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88

99
import java.time.LocalDate;
1010

11+
/**
12+
* Represetns a command telling to list all tasks on a specified date
13+
*/
1114
public class CheckCommand implements Command{
1215
private LocalDate date;
1316

17+
/**
18+
* Constructor
19+
* @param date Date to check
20+
*/
1421
public CheckCommand(LocalDate date) {
1522
this.date = date;
1623
}
@@ -19,6 +26,7 @@ public boolean isExit() {
1926
return false;
2027
}
2128

29+
/** */
2230
public void execute(TaskList tasks, Ui ui, Storage storage) {
2331
TaskList filteredList = new TaskList();
2432

src/main/java/duke/command/Command.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@
55

66
import duke.task.TaskList;
77

8+
/**
9+
* Represents a command to duke
10+
*/
811
public interface Command {
12+
/**
13+
* Checks if the command is an exit command
14+
* @return True if is an exit command, false otherwise
15+
*/
916
public boolean isExit();
1017

18+
/**
19+
* Executes the command
20+
*
21+
* @param tasks List of tasks to operate on
22+
* @param ui User interface for user interaction
23+
* @param storage Storage manager for loading and saving task files
24+
*/
1125
public void execute(TaskList tasks, Ui ui, Storage storage);
1226
}

src/main/java/duke/command/DeleteCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
import duke.task.Task;
88
import duke.task.TaskList;
99

10+
/**
11+
* Represents a command telling duke to delete a task
12+
*/
1013
public class DeleteCommand implements Command {
1114
private int taskNum;
1215

16+
/**
17+
* Constructor
18+
*
19+
* @param taskNum The task number of the task to be deleted
20+
*/
1321
public DeleteCommand(int taskNum) {
1422
this.taskNum = taskNum;
1523
}

src/main/java/duke/command/DoneCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66

77
import duke.task.TaskList;
88

9+
/**
10+
* Represents a command telling duke to mark a task as complete
11+
*/
912
public class DoneCommand implements Command {
1013
private int taskNum;
1114

15+
/**
16+
* Constructor
17+
*
18+
* @param taskNum Task number of the task to be marked as complete
19+
*/
1220
public DoneCommand(int taskNum) {
1321
this.taskNum = taskNum;
1422
}

0 commit comments

Comments
 (0)