Skip to content

Commit f9badc9

Browse files
committed
Added processing for respective user commands in EventCommand subclasses AddEventCommand, DeleteEventCommand, ListCalendarEventsCommand and UnknownCommand
1 parent 9b0ac8b commit f9badc9

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
package seedu.duke.calendar.command;
22

3+
import seedu.duke.calendar.Calendar;
4+
5+
import java.time.LocalDateTime;
6+
import java.util.Scanner;
7+
38
public class AddEventCommand extends EventCommand{
9+
public void execute(Scanner scanner, Calendar calendar) {
10+
System.out.print("Enter the event name: ");
11+
String eventName = scanner.nextLine();
12+
System.out.print("Enter the event from date (yyyy-mm-ddThh:mm:ss) (eg. 2023-12-20T12:30:30): ");
13+
LocalDateTime eventFrom = LocalDateTime.parse(scanner.nextLine());
14+
System.out.print("Enter the event to date (yyyy-mm-ddThh:mm:ss) (eg. 2023-12-20T12:30:30): ");
15+
LocalDateTime eventTo = LocalDateTime.parse(scanner.nextLine());
16+
17+
calendar.addEvent(eventName, eventFrom, eventTo);
418

19+
System.out.println("Success! Event has been added to your Calendar!");
20+
}
521
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
package seedu.duke.calendar.command;
22

3+
import seedu.duke.calendar.Calendar;
4+
5+
import java.time.LocalDateTime;
6+
import java.util.Scanner;
7+
38
public class DeleteEventCommand extends EventCommand{
9+
public void execute(Scanner scanner, Calendar calendar) {
10+
System.out.print("Enter the event name: ");
11+
String eventName = scanner.nextLine();
12+
13+
calendar.delEvent(eventName);
14+
15+
System.out.println("Event has been deleted from your Calendar!");
16+
}
417
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
package seedu.duke.calendar.command;
22

3+
import seedu.duke.calendar.Calendar;
4+
5+
import java.util.Scanner;
6+
37
public class ListCalendarEventsCommand extends EventCommand{
8+
public void execute(Scanner scanner, Calendar calendar) {
9+
calendar.listEvents();
10+
}
411
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
package seedu.duke.calendar.command;
22

3+
import seedu.duke.calendar.Calendar;
4+
5+
import java.util.Scanner;
6+
37
public class UnknownCommand extends EventCommand{
8+
public void execute(Scanner scanner, Calendar calendar) {
9+
System.out.println("Unknown command!");
10+
}
411
}

0 commit comments

Comments
 (0)