Skip to content

Commit 115bdba

Browse files
authored
Merge pull request #69 from Brian030601/master
Add FindEvent & DeleteAll
2 parents 19841ea + 5d72f0b commit 115bdba

File tree

8 files changed

+90
-8
lines changed

8 files changed

+90
-8
lines changed

docs/DeveloperGuide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ As such, computer science students represent good target users of TaskLinker.
4545

4646
TaskLinker is a CLI-tool for helping university students memorize flashcards
4747
and track their flashcard and general academic progress in the courses they are
48-
taking.
48+
taking.
4949

5050

5151
## User Stories

docs/UserGuide.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ taking.
99
## Quick Start
1010

1111
1. Ensure that you have Java 11 or above installed.
12-
1. Down the latest jar from [the latest release on GitHub]
12+
2. Down the latest jar from [the latest release on GitHub]
1313
(https://github.com/AY2324S1-CS2113-F11-3/tp/releases).
14-
1. Run the jar via `java -jar duke.jar`
14+
3. Run the jar via `java -jar duke.jar`
1515

1616
## General explanation of flashcards
1717

@@ -80,6 +80,28 @@ of pressing <ENTER> to reveal the back page.
8080

8181
Format: `create flashcard`
8282

83+
## General explanation of calendar features
84+
85+
## Features
86+
- `add event` , `delete event`
87+
- `list events` , `find event`
88+
- `delete all events`
89+
90+
### Add an Event to the Calendar: `add event`
91+
92+
- **Adds an event to the calendar with start and end time**
93+
94+
Format: `add event`
95+
96+
* The `DEADLINE` can be in a natural language format.
97+
* The `TODO_NAME` cannot contain punctuation.
98+
99+
Example of usage:
100+
101+
`todo n/Write the rest of the User Guide d/next week`
102+
103+
`todo n/Refactor the User Guide to remove passive voice d/13/04/2020`
104+
83105
## FAQ
84106

85107
**Q**: Where can I find my flashcard and caldendar data?

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
package seedu.duke.calendar;
44

55
import seedu.duke.calendar.command.AddEventCommand;
6+
import seedu.duke.calendar.command.DeleteAllEvents;
67
import seedu.duke.calendar.command.DeleteEventCommand;
78
import seedu.duke.calendar.command.EventCommand;
8-
import seedu.duke.calendar.command.ListCalendarEventsCommand;
99
import seedu.duke.calendar.command.UnknownCommand;
10+
import seedu.duke.calendar.command.FindEvent;
11+
import seedu.duke.calendar.command.ListCalendarEventsCommand;
1012

1113
public class CalendarCommandParser {
1214
public EventCommand parseInput(String input) {
@@ -16,8 +18,12 @@ public EventCommand parseInput(String input) {
1618
return new AddEventCommand();
1719
} else if (input.startsWith("delete event")) {
1820
return new DeleteEventCommand();
19-
} else if (input.startsWith("list event")) {
21+
} else if (input.startsWith("list events")) {
2022
return new ListCalendarEventsCommand();
23+
} else if (input.startsWith("delete all events")) {
24+
return new DeleteAllEvents();
25+
} else if (input.startsWith("find event")) {
26+
return new FindEvent();
2127
}
2228

2329
return new UnknownCommand();

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package seedu.duke.calendar;
1+
//@@ kherlenbayasgalan
22

3+
package seedu.duke.calendar;
34

45
import java.util.ArrayList;
56

@@ -19,12 +20,27 @@ public ArrayList<Event> getEvent() {
1920
}
2021

2122
// for logging
22-
public int getSize(){ return eventList.size();}
23+
public int getSize() {
24+
return eventList.size();
25+
}
26+
27+
public void findEvent(String keyword) {
28+
int count = 0;
29+
for (Event event: eventList) {
30+
if (event.getName().contains(keyword)) {
31+
System.out.println((++count) + ". " + event);
32+
}
33+
}
34+
}
2335

2436
public void deleteEvent(String name) {
2537
eventList.removeIf(event -> event.getName().equals(name));
2638
}
2739

40+
public void deleteAllEvents() {
41+
eventList.clear();
42+
}
43+
2844
@Override
2945
public String toString() {
3046
return "EventStorage{" +

src/main/java/seedu/duke/calendar/command/AddEventCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.Scanner;
99
import java.time.LocalDateTime;
1010

11-
public class AddEventCommand extends EventCommand{
11+
public class AddEventCommand extends EventCommand {
1212
public void execute(Scanner scanner, EventList eventList) {
1313
System.out.print("What's the event?: ");
1414
String eventName = scanner.nextLine();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@@ kherlenbayasgalan
2+
3+
package seedu.duke.calendar.command;
4+
5+
import seedu.duke.calendar.EventList;
6+
7+
import java.util.Scanner;
8+
9+
public class DeleteAllEvents extends EventCommand {
10+
public void execute(Scanner scanner, EventList eventList) {
11+
eventList.deleteAllEvents();
12+
13+
System.out.println(" All your events have been successfully " +
14+
"deleted from the calendar.");
15+
}
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@@ kherlenbayasgalan
2+
3+
package seedu.duke.calendar.command;
4+
5+
import seedu.duke.calendar.Event;
6+
import seedu.duke.calendar.EventList;
7+
8+
import java.util.Scanner;
9+
10+
public class FindEvent extends EventCommand {
11+
public void execute(Scanner scanner, EventList eventList) {
12+
System.out.print("What event are you looking for?: ");
13+
String eventName = scanner.nextLine();
14+
15+
System.out.println("Here are the matching events in your list:");
16+
eventList.findEvent(eventName);
17+
18+
System.out.println(" These events have been found");
19+
System.out.print("Enter your command: ");
20+
}
21+
}

src/main/java/seedu/duke/flashcard/FlashcardCommandParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package seedu.duke.flashcard;
44

5+
import seedu.duke.calendar.command.FindEvent;
56
import seedu.duke.flashcard.command.FlashcardCommand;
67
import seedu.duke.flashcard.command.CreateFlashcardCommand;
78
import seedu.duke.flashcard.command.ListFlashcardsCommand;

0 commit comments

Comments
 (0)