forked from nus-cs2113-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2113-AY2324S1#4 from AY2324S1-CS2113-F11-3/m…
…aster Update
- Loading branch information
Showing
32 changed files
with
415 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ checkstyle { | |
toolVersion = '10.2' | ||
} | ||
|
||
run{ | ||
run { | ||
standardInput = System.in | ||
enableAssertions = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
submit v1.0 | 2023-10-29T23:59:59 | 2023-10-30T23:59:59 | ||
eat dinner | 2023-12-20T19:00 | 2023-12-20T20:00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
d | a | - | - | - | ||
dfdf | dfdf | - | - | - | ||
dfdf | asdfdf | - | - | - | ||
ddf | dfdf | - | - | - | ||
hello | bye | - | - | - | ||
hello | bye | - | - | - | ||
end program | hello | - | - | - | ||
hello | world | - | - | - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
//@@ kherlenbayasgalan & jingxizhu | ||
|
||
package seedu.duke.calendar; | ||
|
||
public class Calendar { | ||
EventStorage eventStorage; | ||
EventList eventList; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,72 @@ | ||
//@@ kherlenbayasgalan & jingxizhu | ||
|
||
package seedu.duke.calendar; | ||
|
||
import seedu.duke.calendar.command.EventCommand; | ||
import seedu.duke.calendar.command.UnknownCommand; | ||
import seedu.duke.calendar.Event; | ||
import seedu.duke.flashcard.FlashcardStorage; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.util.ArrayList; | ||
import java.util.Scanner; | ||
|
||
public class CalendarManager { | ||
Calendar calendar; | ||
CalendarUi calendarUi; | ||
EventList eventList; | ||
CalendarCommandParser calendarCommandParser; | ||
Scanner scanner; | ||
|
||
private EventStorage storage; | ||
|
||
public CalendarManager(ArrayList<Event> events) { | ||
|
||
EventDirectory eventdirectory = new EventDirectory(); | ||
eventdirectory.listEventFiles(); | ||
|
||
storage = new EventStorage("./data/events/event.txt"); | ||
|
||
try{ | ||
eventList = storage.loadEvents(); | ||
} catch (FileNotFoundException e){ | ||
System.out.println("Making new file for Events"); | ||
eventList = new EventList(events); | ||
} | ||
|
||
public CalendarManager() { | ||
calendar = new Calendar(); | ||
calendarUi = new CalendarUi(); | ||
calendarUi = new CalendarUi(eventList); | ||
calendarCommandParser = new CalendarCommandParser(); | ||
scanner = new Scanner(System.in); | ||
|
||
} | ||
|
||
public void start() { | ||
public EventStorage getStorage(){ | ||
return this.storage; | ||
} | ||
|
||
public boolean validCommand(String input) { | ||
EventCommand command = calendarCommandParser.parseInput(input); | ||
|
||
return !(command instanceof UnknownCommand); | ||
} | ||
|
||
public boolean isResponsible(String input) { | ||
return validCommand(input); | ||
} | ||
|
||
public void processInput(String input) { | ||
startCalendar(input); | ||
|
||
storage.saveEvents(eventList.getEvent()); | ||
} | ||
|
||
public void startCalendar(String input) { | ||
EventCommand command = calendarCommandParser.parseInput(input); | ||
assert !(command instanceof seedu.duke.calendar.command.UnknownCommand) : | ||
"Command cannot be " + "unknown"; | ||
calendarUi.executeCommand(command); | ||
//calendarCommandParser.parseInput(command); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
package seedu.duke.calendar; | ||
|
||
import seedu.duke.calendar.command.EventCommand; | ||
|
||
import java.util.Scanner; | ||
|
||
public class CalendarUi { | ||
private Scanner scanner; | ||
private EventList eventList; | ||
|
||
public CalendarUi (EventList eventList) { | ||
scanner = new Scanner(System.in); | ||
this.eventList = eventList; | ||
} | ||
|
||
public void executeCommand(EventCommand command) { | ||
command.execute(scanner, eventList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package seedu.duke.calendar; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* directory for directory | ||
* can list-up txt files in text folder | ||
* In version 1, using only event.txt | ||
* In version 2, can select or create | ||
*/ | ||
|
||
public class EventDirectory { | ||
String path; | ||
File file; | ||
|
||
public EventDirectory(){ | ||
path = "./data/events"; | ||
|
||
file = new File(path); | ||
if(!file.exists()){ | ||
if(file.mkdir()){ | ||
System.out.println(" Created events directory"); | ||
} else{ | ||
System.out.println(" Failed to create directory"); | ||
} | ||
} else{ | ||
System.out.println(" Using data/events directory"); | ||
} | ||
} | ||
|
||
/** | ||
* list-up saved files | ||
* selecting file is for version 2 | ||
*/ | ||
public void listEventFiles(){ | ||
String[] eventFiles = file.list(); | ||
if(eventFiles == null){ | ||
System.out.println("Failed to find files"); | ||
} else if(eventFiles.length == 0){ | ||
System.out.println("No files exist"); | ||
} else{ | ||
for(String eventFile : eventFiles){ | ||
System.out.println(" "+eventFile); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* return default directory | ||
* for version 1 | ||
* @return directory for flashcard txt file | ||
*/ | ||
public String defaultDirectory() { | ||
return this.path + "/event.txt"; | ||
} | ||
|
||
/** | ||
* return directory of flashcard txt file | ||
* for version 2 | ||
* @param path | ||
* @return | ||
*/ | ||
public String eventDirectory(String path) { | ||
return this.path + path; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package seedu.duke.calendar; | ||
|
||
|
||
import java.util.ArrayList; | ||
|
||
public class EventList { | ||
private ArrayList<Event> eventList; | ||
|
||
public EventList(ArrayList<Event> eventList) { | ||
this.eventList = eventList; | ||
} | ||
|
||
public void addEvent(Event event) { | ||
eventList.add(event); | ||
} | ||
|
||
public ArrayList<Event> getEvent() { | ||
return eventList; | ||
} | ||
|
||
public int getSize(){ return eventList.size();} | ||
|
||
public void deleteEvent(String name) { | ||
eventList.removeIf(event -> event.getName().equals(name)); | ||
} | ||
@Override | ||
public String toString() { | ||
return "EventStorage{" + | ||
"events=" + eventList + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.