Skip to content

Commit b60ffc3

Browse files
authored
Merge pull request nus-cs2113-AY2324S1#4 from AY2324S1-CS2113-F11-3/master
Update
2 parents f0693f5 + 913c42c commit b60ffc3

32 files changed

+415
-81
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ Steps for publishing documentation to the public:
6262
1. Scroll down to the `GitHub Pages` section.
6363
1. Set the `source` as `master branch /docs folder`.
6464
1. Optionally, use the `choose a theme` button to choose a theme for your documentation.
65+

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ checkstyle {
4141
toolVersion = '10.2'
4242
}
4343

44-
run{
44+
run {
4545
standardInput = System.in
4646
enableAssertions = true
4747
}

data/events/event.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
submit v1.0 | 2023-10-29T23:59:59 | 2023-10-30T23:59:59
2+
eat dinner | 2023-12-20T19:00 | 2023-12-20T20:00

data/flashcards/flashcard.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
d | a | - | - | -
2+
dfdf | dfdf | - | - | -
3+
dfdf | asdfdf | - | - | -
4+
ddf | dfdf | - | - | -
5+
hello | bye | - | - | -
6+
hello | bye | - | - | -
7+
end program | hello | - | - | -
8+
hello | world | - | - | -

src/main/java/seedu/duke/Duke.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
package seedu.duke;
44

5-
import seedu.duke.flashcard.Flashcard;
5+
import seedu.duke.calendar.CalendarManager;
66
import seedu.duke.flashcard.FlashcardComponent;
7-
import seedu.duke.flashcard.FlashcardDirectory;
87

98
import java.util.ArrayList;
109
import java.util.Scanner;
@@ -17,7 +16,8 @@ public static void main(String[] args) {
1716
}
1817

1918
private void run() {
20-
FlashcardComponent fc = new FlashcardComponent(new ArrayList<Flashcard>());
19+
FlashcardComponent fc = new FlashcardComponent();
20+
CalendarManager cm = new CalendarManager(new ArrayList<>());
2121

2222
Scanner scanner = new Scanner(System.in);
2323
String input;
@@ -28,8 +28,13 @@ private void run() {
2828

2929
if (fc.isResponsible(input)) {
3030
fc.processInput(input);
31+
32+
} else if (cm.isResponsible(input)) {
33+
cm.processInput(input);
34+
} else {
35+
System.out.println(" Invalid command! Please try again.");
3136
}
3237
}
3338

3439
}
35-
}
40+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
//@@ kherlenbayasgalan & jingxizhu
2+
13
package seedu.duke.calendar;
24

35
public class Calendar {
4-
EventStorage eventStorage;
6+
EventList eventList;
57
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@@ kherlenbayasgalan & jingxizhu
2+
13
package seedu.duke.calendar;
24

35
import seedu.duke.calendar.command.AddEventCommand;
Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,72 @@
1+
//@@ kherlenbayasgalan & jingxizhu
2+
13
package seedu.duke.calendar;
24

5+
import seedu.duke.calendar.command.EventCommand;
6+
import seedu.duke.calendar.command.UnknownCommand;
7+
import seedu.duke.calendar.Event;
8+
import seedu.duke.flashcard.FlashcardStorage;
9+
10+
import java.io.FileNotFoundException;
11+
import java.util.ArrayList;
12+
import java.util.Scanner;
13+
314
public class CalendarManager {
415
Calendar calendar;
516
CalendarUi calendarUi;
17+
EventList eventList;
618
CalendarCommandParser calendarCommandParser;
19+
Scanner scanner;
20+
21+
private EventStorage storage;
22+
23+
public CalendarManager(ArrayList<Event> events) {
24+
25+
EventDirectory eventdirectory = new EventDirectory();
26+
eventdirectory.listEventFiles();
27+
28+
storage = new EventStorage("./data/events/event.txt");
29+
30+
try{
31+
eventList = storage.loadEvents();
32+
} catch (FileNotFoundException e){
33+
System.out.println("Making new file for Events");
34+
eventList = new EventList(events);
35+
}
736

8-
public CalendarManager() {
937
calendar = new Calendar();
10-
calendarUi = new CalendarUi();
38+
calendarUi = new CalendarUi(eventList);
1139
calendarCommandParser = new CalendarCommandParser();
40+
scanner = new Scanner(System.in);
41+
1242
}
1343

14-
public void start() {
44+
public EventStorage getStorage(){
45+
return this.storage;
46+
}
47+
48+
public boolean validCommand(String input) {
49+
EventCommand command = calendarCommandParser.parseInput(input);
50+
51+
return !(command instanceof UnknownCommand);
52+
}
53+
54+
public boolean isResponsible(String input) {
55+
return validCommand(input);
56+
}
57+
58+
public void processInput(String input) {
59+
startCalendar(input);
60+
61+
storage.saveEvents(eventList.getEvent());
62+
}
1563

64+
public void startCalendar(String input) {
65+
EventCommand command = calendarCommandParser.parseInput(input);
66+
assert !(command instanceof seedu.duke.calendar.command.UnknownCommand) :
67+
"Command cannot be " + "unknown";
68+
calendarUi.executeCommand(command);
69+
//calendarCommandParser.parseInput(command);
1670
}
1771

1872
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
package seedu.duke.calendar;
22

3+
import seedu.duke.calendar.command.EventCommand;
4+
5+
import java.util.Scanner;
6+
37
public class CalendarUi {
8+
private Scanner scanner;
9+
private EventList eventList;
10+
11+
public CalendarUi (EventList eventList) {
12+
scanner = new Scanner(System.in);
13+
this.eventList = eventList;
14+
}
15+
16+
public void executeCommand(EventCommand command) {
17+
command.execute(scanner, eventList);
18+
}
419
}

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
//@@author @@kherlenbayasgalan & @@ Jingxizhu
2+
13
package seedu.duke.calendar;
24

3-
import java.time.LocalDate;
5+
import java.time.LocalDateTime;
46

57
public class Event {
6-
String name;
7-
LocalDate from;
8-
LocalDate to;
8+
private String name;
9+
private LocalDateTime from;
10+
private LocalDateTime to;
911

10-
public Event(String name, LocalDate from, LocalDate to) {
12+
public Event(String name, LocalDateTime from, LocalDateTime to) {
1113
this.name = name;
1214
this.from = from;
1315
this.to = to;
@@ -21,19 +23,19 @@ public void setName(String name) {
2123
this.name = name;
2224
}
2325

24-
public LocalDate getFrom() {
26+
public LocalDateTime getFrom() {
2527
return from;
2628
}
2729

28-
public void setFrom(LocalDate from) {
30+
public void setFrom(LocalDateTime from) {
2931
this.from = from;
3032
}
3133

32-
public LocalDate getTo() {
34+
public LocalDateTime getTo() {
3335
return to;
3436
}
3537

36-
public void setTo(LocalDate to) {
38+
public void setTo(LocalDateTime to) {
3739
this.to = to;
3840
}
3941

0 commit comments

Comments
 (0)