Skip to content

Commit f68a5b5

Browse files
authored
Merge pull request #120 from Brian030601/master
Add Documentation
2 parents 67360f0 + 0658db7 commit f68a5b5

22 files changed

+183
-20
lines changed

docs/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Duke
1+
# TaskLinker
22

3-
{Give product intro here}
3+
TaskLinker is a CLI-tool for helping university students memorize flashcards
4+
and track their flashcard and general academic progress in the courses they are
5+
taking.
46

57
Useful links:
68
* [User Guide](UserGuide.md)

src/main/java/seedu/duke/calendar/Calendar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
public class Calendar {
66
/**
7-
* Here for integrating Flashcard goals with Calendar
7+
* The class is here for integrating Flashcard goals with the Calendar.
8+
* Any other features related to the Calendar can be added here in the future.
89
*/
910

1011
EventList eventList;

src/main/java/seedu/duke/calendar/CalendarCommandParser.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
import java.util.Scanner;
2020

2121
public class CalendarCommandParser {
22+
23+
/**
24+
* The manageException method is used to throw exceptions if those exceptions have
25+
* been encountered. Each if case handles different exception errors. The method
26+
* has one parameter (String userInput), which is used to check if the input has
27+
* anything else after it.
28+
* @param userInput is taken to check if the condition matches the exception.
29+
* @throws AddEventException is thrown if the user only inputs add and nothing else.
30+
* @throws DeleteEventException is thrown if the user only inputs delete all and nothing else.
31+
* @throws DeleteAllException is thrown if the user only inputs delete and nothing else.
32+
* @throws FindEventException is thrown if the user only inputs find and nothing else.
33+
* @throws ListEventException is thrown if the user only inputs list and nothing else.
34+
*/
35+
2236
public static void manageException(String userInput) throws AddEventException, DeleteEventException,
2337
DeleteAllException, FindEventException, ListEventException {
2438

@@ -42,7 +56,17 @@ public static void manageException(String userInput) throws AddEventException, D
4256
}
4357
}
4458

59+
/**
60+
* The parseInput method is used to catch any exceptions that could occur. The method
61+
* has one parameter (String input). The input is used for asserting that it is not null.
62+
* If any exceptions are caught, then the corresponding messages are displayed.
63+
* Last resort unknown command will run if the command is not recognized.
64+
* @param input is used to check whether input is null or not.
65+
* @return runs the commands
66+
*/
67+
4568
public EventCommand parseInput(String input) {
69+
// using asser to check whether the input is null.
4670
assert input != null : "input is null";
4771

4872
try {

src/main/java/seedu/duke/calendar/CalendarManager.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public class CalendarManager {
1818

1919
private EventStorage storage;
2020

21+
/**
22+
* The CalendarManager initializes the accesses to other classes.
23+
* It also loads events from the storage.
24+
* @param events is used to initialize the EventList.
25+
*/
26+
2127
public CalendarManager(ArrayList<Event> events) {
2228

2329
EventDirectory eventdirectory = new EventDirectory();
@@ -39,32 +45,46 @@ public CalendarManager(ArrayList<Event> events) {
3945

4046
}
4147

48+
// getStorage is used for getting the storage
4249
public EventStorage getStorage(){
4350
return this.storage;
4451
}
4552

53+
/**
54+
* validCommand is used for checking whether the command is valid, and
55+
* not an instance of UnknownCommand.
56+
* @param input is used for converting the input into command.
57+
* @return returns whether the command is instance of UnknownCommand or not.
58+
*/
59+
4660
public boolean validCommand(String input) {
4761
EventCommand command = calendarCommandParser.parseInput(input);
4862

4963
return !(command instanceof UnknownCommand);
5064
}
5165

66+
// isResponsible calls the validCommand method.
5267
public boolean isResponsible(String input) {
5368
return validCommand(input);
5469
}
5570

71+
// processInput is used for saving the events in the EventList.
5672
public void processInput(String input) {
5773
startCalendar(input);
5874

5975
storage.saveEvents(eventList.getEvent());
6076
}
6177

78+
/**
79+
* startCalender starts the Calendar features and uses the input as a command.
80+
* @param input is used for converting the input into command.
81+
*/
82+
6283
public void startCalendar(String input) {
6384
EventCommand command = calendarCommandParser.parseInput(input);
6485
assert !(command instanceof seedu.duke.calendar.command.UnknownCommand) :
6586
"Command cannot be " + "unknown";
6687
calendarUi.executeCommand(command);
6788
//calendarCommandParser.parseInput(command);
6889
}
69-
7090
}

src/main/java/seedu/duke/calendar/CalendarUi.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ public class CalendarUi {
88
private Scanner scanner;
99
private EventList eventList;
1010

11+
// CalendarUi is the constructor method for CalendarUi class.
1112
public CalendarUi (EventList eventList) {
1213
scanner = new Scanner(System.in);
1314
this.eventList = eventList;
1415
}
1516

17+
/**
18+
* executeCommand is used for starting the calendar part of the program.
19+
* @param command is used for relaying the command entered by the user.
20+
*/
21+
1622
public void executeCommand(EventCommand command) {
1723
command.execute(scanner, eventList);
1824
}

src/main/java/seedu/duke/calendar/Event.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,44 @@ public class Event {
99
private LocalDateTime from;
1010
private LocalDateTime to;
1111

12+
// Event is a constructor method for Event class.
1213
public Event(String name, LocalDateTime from, LocalDateTime to) {
1314
this.name = name;
1415
this.from = from;
1516
this.to = to;
1617
}
1718

19+
// getName returns the name of the event.
1820
public String getName() {
1921
return name;
2022
}
2123

24+
// setName is used for setting the event name.
2225
public void setName(String name) {
2326
this.name = name;
2427
}
2528

29+
// getFrom is used for getting the start time of an Event.
2630
public LocalDateTime getFrom() {
2731
return from;
2832
}
2933

34+
// setFrom is used for setting the start time of an Event.
3035
public void setFrom(LocalDateTime from) {
3136
this.from = from;
3237
}
3338

39+
// getFrom is used for getting the end time of an Event.
3440
public LocalDateTime getTo() {
3541
return to;
3642
}
3743

44+
// setFrom is used for setting the end time of an Event.
3845
public void setTo(LocalDateTime to) {
3946
this.to = to;
4047
}
4148

49+
// toString is used for formatting the print version of an Event.
4250
@Override
4351
public String toString() {
4452
return "Event '" + name + '\'' +

src/main/java/seedu/duke/calendar/EventDirectory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public String defaultDirectory() {
8585
/**
8686
* return directory of flashcard txt file
8787
* for version 2
88-
* @param path
89-
* @return
88+
* @param path is used for storing file path
89+
* @return is used to get the path to the file
9090
*/
9191
public String eventDirectory(String path) {
9292
return this.path + path;

src/main/java/seedu/duke/calendar/EventList.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,27 @@
77
public class EventList {
88
private ArrayList<Event> eventList;
99

10+
// EventList is a constructor method
1011
public EventList(ArrayList<Event> eventList) {
1112
this.eventList = eventList;
1213
}
1314

15+
// addEvent is used for adding an event to the EventList.
1416
public void addEvent(Event event) {
1517
eventList.add(event);
1618
}
1719

20+
// getEvent is used to get an event from the EventList.
1821
public ArrayList<Event> getEvent() {
1922
return eventList;
2023
}
2124

22-
// for logging
25+
// getSize is used for getting the size of EventList.
2326
public int getSize() {
2427
return eventList.size();
2528
}
2629

30+
// findEvent is used for finding a specific event from the EventList.
2731
public int findEvent(String keyword) {
2832
int count = 0;
2933
for (Event event: eventList) {
@@ -35,6 +39,7 @@ public int findEvent(String keyword) {
3539
return count;
3640
}
3741

42+
// deleteEvent is used for deleting an event from the EventList
3843
public int deleteEvent(String name) {
3944
int size = eventList.size();
4045
if (size > 0) {
@@ -46,10 +51,12 @@ public int deleteEvent(String name) {
4651
return size;
4752
}
4853

54+
// deleteAllEvents is used for deleting all events in the EventList.
4955
public void deleteAllEvents() {
5056
eventList.clear();
5157
}
5258

59+
// toString formats the print version of EventList.
5360
@Override
5461
public String toString() {
5562
return "EventStorage{" +

src/main/java/seedu/duke/calendar/EventStorage.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public boolean isStorageAvailable(){
3232
}
3333

3434
/**
35-
* load a event from certain format
35+
* load an event from certain format
3636
* Tokens includes attributes of Event
37-
* @param tokens
37+
* @param tokens is used to get event name
3838
* @return Event object
3939
*/
4040
private Event loadEvent(String[] tokens){
@@ -52,7 +52,7 @@ private Event loadEvent(String[] tokens){
5252
* load list of events
5353
* from this.path
5454
* @return list of Events
55-
* @throws FileNotFoundException
55+
* @throws FileNotFoundException is used if the file is not in the path
5656
*/
5757
public EventList loadEvents() throws FileNotFoundException{
5858
EventList eventList = new EventList(new ArrayList<>());
@@ -65,7 +65,7 @@ public EventList loadEvents() throws FileNotFoundException{
6565
}
6666

6767
logger.log(Level.INFO, String.format(
68-
" There are currently %d events in the savefile",
68+
" There are currently %d events in the save file",
6969
eventList.getSize()));
7070

7171
return eventList;
@@ -75,15 +75,14 @@ public EventList loadEvents() throws FileNotFoundException{
7575
/**
7676
* saveEvents method
7777
* save all events to file
78-
* @param eventList
78+
* @param eventList is used to access the list
7979
*/
8080
public void saveEvents(ArrayList<Event> eventList) {
8181

8282
try {
8383
FileWriter fw = new FileWriter(path);
8484

85-
for (int i = 0; i < eventList.size(); i++) {
86-
Event event = eventList.get(i);
85+
for (Event event : eventList) {
8786
fw.write(String.format("%s | %s | %s \r\n",
8887
event.getName(), event.getFrom(), event.getTo()));
8988
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package seedu.duke.calendar.Exceptions;
22

3+
/**
4+
* The AddEventException class is used for handling exceptions related with adding an event
5+
*/
6+
37
public class AddEventException extends Exception {
48

59
}

0 commit comments

Comments
 (0)