File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed
Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ T | 1 | read book
22D | 1 | return book | 2pm | 2020-02-01
33D | 0 | submit code | 5pm | 2020-01-30
44E | 0 | meeting | 8am | 2020-01-30
5- T | 0 | nap
5+ T | 0 | nap
66E | 0 | meeting | 1pm | 2020-02-01
77D | 0 | tutorial | 2pm | 2020-02-02
Original file line number Diff line number Diff line change @@ -15,10 +15,10 @@ public Duke(String filePath) {
1515 // following code from module website
1616
1717 ui = new Ui ();
18- storage = new Storage (filePath );
1918 parser = new Parser ();
2019
2120 try {
21+ storage = new Storage (filePath );
2222 tasks = new TaskList (storage .load ());
2323 } catch (DukeException e ) {
2424 ui .showError (e );
@@ -28,7 +28,7 @@ public Duke(String filePath) {
2828
2929 public void run () {
3030 // following code from module website
31-
31+
3232 ui .greet ();
3333
3434 boolean isExit = false ;
Original file line number Diff line number Diff line change 1+ Manifest-Version : 1.0
2+ Main-Class : Duke
3+
Original file line number Diff line number Diff line change @@ -12,9 +12,18 @@ public class Storage {
1212 protected String filePath ;
1313 protected File file ;
1414
15- public Storage (String filePath ) {
15+ public Storage (String filePath ) throws DukeException {
1616 this .filePath = filePath ;
17+
18+ // file creation following code from
19+ // https://stackoverflow.com/questions/6142901/how-to-create-a-file-in-a-directory-in-java/6143076#6143076
1720 file = new File (filePath );
21+ try {
22+ file .getParentFile ().mkdirs ();
23+ file .createNewFile ();
24+ } catch (IOException e ) {
25+ throw new DukeException (" Oh no, file could not be created!\n " );
26+ }
1827 }
1928
2029 public ArrayList <Task > load () throws DukeException {
You can’t perform that action at this time.
0 commit comments