From 7558b46825723cabfb327deef903da61b2f10fd7 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Wed, 1 Feb 2023 13:37:43 +0800 Subject: [PATCH 01/31] Level 0 Greet --- src/main/java/Duke.class | Bin 0 -> 635 bytes src/main/java/Duke.java | 5 ++++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 src/main/java/Duke.class diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class new file mode 100644 index 0000000000000000000000000000000000000000..d8e03c6de24f20caa69fa399148daa5fb618de5d GIT binary patch literal 635 zcmZuuU279T6g`u#-E5<^iHRR=^~OFlEz*4~*rE>>jSy6b_+nt$q(j_xcPAvfN@4$0 zeNgbhAK;G?&!oi?aE86-?wND%%$)iC=jSf~huHB@N7F^Cj=N~P=yC_)) z^C+Dj*+Oq<^7%x+imbSPlAr4Xt82i+n!-W?4!Iux60Z;mWWA}LV9KT;#--e zm#V8Ma?Gm0_X^wFmr)Qr4Y)K4m<5IBV7q}wc&xC|*KusR@@6*?dotmgG|4H4lvzm%+rEurQj(6iTJ;_$6 z;l(1;3Eee07ur|eMaF+m<1*T(!{msESoT<@6`YwB#dN*h`=9B&fXfHAqXfPH))*W7 z+a@Yvb^iy{B@=~PjI|}n*THS9Gq=(cmX?TH&C=i-%FW7mR4vx7(IMV+=%7k%nbYNF Qb+owYCj0Qp Date: Wed, 1 Feb 2023 14:36:07 +0800 Subject: [PATCH 02/31] Level 1. Greet, Echo, Exit --- src/main/java/Duke.class | Bin 635 -> 1113 bytes src/main/java/Duke.java | 33 ++++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index d8e03c6de24f20caa69fa399148daa5fb618de5d..166d629cf95aacc15dac82152f5aad183b3dc7f1 100644 GIT binary patch literal 1113 zcmZuxYfsZq7=F%f?MgS;7|6xT8KP`}tAdI$6cwWo@RH1!s3c7{PDY_?=hmtu`y>7W zKg$Oon)n0!Pa5A-7U$G9J?HIno<8sGoPPiLoKG%zE#_QVl_jKf<;LJOipm$ZE!=wZMC ze=f-8tFHLq%bmrLD-{3Lrrjvs2A0$Q%k^o_<>G6Gc+K(J0(siPSvm|r43r0QG>*{Q zIhq;G@!4ar&t%Y6q%jeKQ6yzm$(GbLL_&1(5Rq*32(fH@lgwGNB$A-HCoqb5D5KK( z8Guf{Q*^A-BuEYG3LYRzlEC6uD6bBo9wWI)YT8zIVD1R|N2H~0igZ6AMJ9o<6QqeU zC>=$@NT;BZogpV#43YFW#X3z<&yk}NCb2*%juS&i%OOqifqoBBs$PPA8jPf*+w;EwBBJ9f delta 264 zcmXYq%`OB{5QV>cdwTBetNlzj?PmtJkq}}nY;0yR5=%QPkq)96o8dVo_Zd6@3kwVO z-oR_vN<_7&N}ZFcI(6#Pez$f$eqP^zJ=PrwnI%t{WzJGK=2@^TT9yo5LvMVtJ$~Ge z91|f{_XmdMloeJLok3OC!_psZ-uV9Ly7JE8Q%cqp`C$0q&(CiCmA|a&J3l(~F1)La z@TIoGu0Ab9X617e8ilwErlE|Ai%FTar9&!Vis@z}U0;-1xR>eUXQHh2LfmlspN;U- Z-&NyK5DP| Date: Wed, 1 Feb 2023 23:45:37 +0800 Subject: [PATCH 03/31] Level 2. Add, List --- src/main/java/Duke.class | Bin 1113 -> 1950 bytes src/main/java/Duke.java | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index 166d629cf95aacc15dac82152f5aad183b3dc7f1..93ecc2676049ead16ae212780f08304935a3bc95 100644 GIT binary patch literal 1950 zcmaJ?-Bue_6#hkZ@9J>Z5J+m0H4FBaH+UYk``#PoFwP$+2=do{yF>X{PFM6?*OjB(9nmG zR$RoWiZKl_#8r%|m{4#@Y9}=)NXQ|n;k4i#v@BSTr2e4A&Ig((xgd7(8y!!|Ts$K|A2w;G6WL z`G6l(Q3faVnNN}@B}}TTsM^T+0_`%A+JWRw@=e3IWY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zT&huR)DN(|56trN7T~sh8U7!4h{JzmAj7KR9;)1PB(u-gFN*!|# ze7PY#iQ{X|O*ya)TTI*K?tmyIOH=viE8S>i3R5s7sxU#Bb<4uE_>GA&Pl72~-Yp6n r&kt#ZQuO%6Cqb|Fkx5pb4yT?8J`?zl7r-mDBbbz^gCgpa-b4Q%$89rG diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index dbcc380f8..740a73770 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -3,14 +3,14 @@ public class Duke { public static void greet_user() { - System.out.println("Hello! I'm Duke \n"); - String logo = " ____ _ \n" + System.out.println("Hello! I'm Duke \n"); + String logo = " ____ _ \n" + "| _ \\ _ _| | _____ \n" + "| | | | | | | |/ / _ \\\n" + "| |_| | |_| | < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println(logo); - System.out.println("How can i help u? \n"); + System.out.println(logo); + System.out.println("How can i help u? \n"); } public static void echo() { @@ -27,10 +27,36 @@ public static void echo() { scan.close(); } + public static void main(String[] args) { greet_user(); - echo(); - } + String[] inputs; + inputs = new String[101]; + int counter = 0; + + Scanner scan = new Scanner(System.in); + String input = scan.nextLine(); + + while (!"bye".equals(input)) { + if ("list".equals(input)) { + for (int i = 0; i < counter; i++) { + System.out.println(i + 1 + "." + " " + inputs[i]); + } + } else { + System.out.println("added: " + input); + inputs[counter] = input; + counter++; + } + scan = new Scanner(System.in); + input = scan.nextLine(); + + } + + System.out.println("Goodbye. Hope to see u again :) \n"); + + scan.close(); + + } } From 50aad959bf23148bc9e6a74b6a9f439cd6798f31 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Thu, 2 Feb 2023 12:52:13 +0800 Subject: [PATCH 04/31] Level-3 Mark as Done --- src/main/java/Duke.class | Bin 1950 -> 2853 bytes src/main/java/Duke.java | 30 ++++++++++++++++++++++++------ src/main/java/Tasks.class | Bin 0 -> 599 bytes src/main/java/Tasks.java | 28 ++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 src/main/java/Tasks.class create mode 100644 src/main/java/Tasks.java diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index 93ecc2676049ead16ae212780f08304935a3bc95..ecc4a3fb393ef1261485d43ecfa3df9855c057de 100644 GIT binary patch literal 2853 zcmai0-FFkm75|MTdDmhMvWzjtfsDa`4Gv03LW1o;f`M4UA4zOT0SB>`26@qHSJAEr zZrqPFw4_PDn=j~7^5WCS<`lyrCwb{x|AapEwWt3dYT^YG#|#|T+!vED@RA-*m>5gqDV#KMDv1G{ z*36eRHEtkl;*}&ia7HsHOiY@X((CCq4zH$ZYF6u>)x$XxZzS;@oY%tzEp^evTp9wG zOyuZan-(NXI$GWW@f^w;}u5+ z&lzxtG~?H*d3D;+ux%%6C3Q%PS~!4%2CiBt!4>EjSFY>#$?X2J)G{(@plrbd?FKT( zk6iscB9co|=HwiIoR{QMB$bn7ulr_XMvG~7Bvl`!9Hmw+lU&l+89A5B4du8smm`&1 zN(yw2`)|v8YxP3f|JEAr&BGWak%^g&M92^u6r+ z1uhTCalfKu=*vJUS(A2=VUxpyGHD@$gBIS_!yz0LNX*(nDG-2$^etT1ka5=uIQ5OI zs**N;;R1hJP!ea60hU@~SXx*_XyLnfM<8{=_roBp+LcKaF8GCDODmR4e9yx7@dFD# z#Jd)Lg!iH(R!atMSokr1V&SIVcwhVS*p!o3eR6ie2_kEfbKWmkTotNs10q%axuVK2kREGZR18>c6n?OZvtD}P?Z^fzecsLdONL6K*sn8i&SkD$PDq6^8DR&Jtt7L%| zUFU0{S+7!C1Kqx=MA*iS=!SXfI^EeiFt`zyp;K?wY?tX?XSROyk--ZrhrH_t42-E^ z^eyEzEGk;I!&;Ed`*dnkK?V7$QwbftN^dli#INxi+7gGPkV2rlY?suS@8#|A4JTY6 z6@<1I(u<=5*^TNOIn9saDz6x_C$O_*dDDa1Jd2NwK(~i%wy942HbqS%>xHVQn~ibJ zc57<-iopJ6sc7(KRfS14nY?pajqOI4;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3#_U8@&+TGHUSBID=8u-?dSh`jz$y~z*}(>yFjc(mU~jLM-A6?9UPLE0Uml}T&U z4%i1$7!H%vOGX7wc_h+<;yrJUNROWqfG9TTbD<124pD@gkVJz-zA%Q?C9sA7Ah!$U z@X&Px<&6>~N?M%2Nrb67V8QVRwH%zo>!dW{|Gmln=(8C2>Qc=ib% zPxdRksdc6A3;66dj2$>9V?~%fs_hD@MOd#eXWJ$1B^s1Y&8LMn5!!~sr>VE1J}tRR z?V<>ELt|U}KerGdUr^meMadcs1=X1i2Ro2{YyS-a?J|mt71!aGR60sjjuQt!6BNX# z?Ktt#LQJ$018t~7JMB8qjZS(^9dx= 4 && input.substring(0, 4).equals("mark")) { + Integer index = Integer.valueOf(input.substring(5, input.length())); + list_of_tasks[index - 1].markAsDone(); + System.out.println("Nice! This task is completed"); + System.out + .println(list_of_tasks[index - 1].getStatusIcon() + " " + list_of_tasks[index - 1].description); + } else if (input.length() >= 6 && input.substring(0, 6).equals("unmark")) { + Integer index = Integer.valueOf(input.substring(7, input.length())); + list_of_tasks[index - 1].markAsUnDone(); + System.out.println("Ok, This task is still not complete"); + System.out + .println(list_of_tasks[index - 1].getStatusIcon() + " " + list_of_tasks[index - 1].description); } else { System.out.println("added: " + input); - inputs[counter] = input; + + list_of_tasks[counter].description = input; + list_of_tasks[counter].isDone = false; counter++; } scan = new Scanner(System.in); diff --git a/src/main/java/Tasks.class b/src/main/java/Tasks.class new file mode 100644 index 0000000000000000000000000000000000000000..2b5bf832f888d253e7cae7253f7d51572884ae32 GIT binary patch literal 599 zcmZutT}#4X7(MScH=R>+IZOM}u5>|O6m(GpQUrn3g%(kCG3Su^F=dl3JJ(4^0F4kdK?=HHWh3!Bs)%E`|db& zM;?RT=vj|eZD4ubS~K)ruY1TKyTR$ma~Rki9gbYj4UZX&$|ARV!yuiEI>gO1T+g|j z4BL+1vf2YeQe7u(hE_NU&TT#`SE(*K5REu?|H2waG6f|Db!hqh`fmua!l!66=-Qhl zQ=6lSZ#!o$AEdUdpdak=muS#nXow@BK}C{5yuW?mwL~=*@feo=-h9>WId(V)&DMZ2 ztxlnR3Xr%R{Yl(0>J$elFr?|UM+|{_#(W1eccu_baSHL3AX*AlorEBvM4|-A()7_l zWPc6zsk6x74dN5xy7Y{g9(y53hz#WDI!i{NM1odVuuM=622~zmn~2;&Hl?}AY81>s X40*cG|HGe8I^!3JUnKrY6kzoSwRdFX literal 0 HcmV?d00001 diff --git a/src/main/java/Tasks.java b/src/main/java/Tasks.java new file mode 100644 index 000000000..fe3ca766d --- /dev/null +++ b/src/main/java/Tasks.java @@ -0,0 +1,28 @@ +public class Tasks { + + protected String description; + protected boolean isDone; + // protected int taskNumber; + + // public String getDescription() { + // return description; + // } + + public Tasks(String description) { + this.description = description; + this.isDone = false; + } + + public String getStatusIcon() { + return (isDone ? "[X]" : "[ ]"); // mark done task with X + } + + public void markAsDone() { + this.isDone = true; + } + + public void markAsUnDone() { + this.isDone = false; + } + +} From 312117e670de03f0bd2d67ea4de86192908e7401 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Thu, 2 Feb 2023 12:53:38 +0800 Subject: [PATCH 05/31] Update Tasks.java --- src/main/java/Tasks.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/Tasks.java b/src/main/java/Tasks.java index fe3ca766d..1f635e57f 100644 --- a/src/main/java/Tasks.java +++ b/src/main/java/Tasks.java @@ -2,11 +2,6 @@ public class Tasks { protected String description; protected boolean isDone; - // protected int taskNumber; - - // public String getDescription() { - // return description; - // } public Tasks(String description) { this.description = description; From 98bc638da15f8cf4597edfb92fcdd9c6928ef5b4 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Thu, 2 Feb 2023 12:56:02 +0800 Subject: [PATCH 06/31] Coding Standard --- src/main/java/Duke.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index cfda9aeb2..456eea726 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -32,7 +32,7 @@ public static void main(String[] args) { greet_user(); int counter = 0; - Tasks[] list_of_tasks = new Tasks[101]; + Tasks[] list_of_tasks = new Tasks[101]; // Following the assumption that there will be no more than 100 tasks for (int k = 0; k < 101; k++) { list_of_tasks[k] = new Tasks(""); } @@ -61,7 +61,6 @@ public static void main(String[] args) { .println(list_of_tasks[index - 1].getStatusIcon() + " " + list_of_tasks[index - 1].description); } else { System.out.println("added: " + input); - list_of_tasks[counter].description = input; list_of_tasks[counter].isDone = false; counter++; @@ -72,9 +71,7 @@ public static void main(String[] args) { } System.out.println("Goodbye. Hope to see u again :) \n"); - scan.close(); - } } From 2306a2a424f26dff9dcc3896361c4d8efbc142ab Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Thu, 9 Feb 2023 14:28:46 +0800 Subject: [PATCH 07/31] Level-4 In progress --- src/main/java/Deadline.java | 15 +++++++++++++++ src/main/java/Duke.class | Bin 2853 -> 2832 bytes src/main/java/Tasks.class | Bin 599 -> 599 bytes src/main/java/Tasks.java | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 src/main/java/Deadline.java diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java new file mode 100644 index 000000000..fb18a1200 --- /dev/null +++ b/src/main/java/Deadline.java @@ -0,0 +1,15 @@ +public class Deadline extends Tasks { + + protected String by; + + public Deadline(String description, String by) { + super(description); + this.by = by; + } + + @Override + public String toString() { + return "[D]" + super.toString() + " (by:" + by + ")"; + } + +} diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index ecc4a3fb393ef1261485d43ecfa3df9855c057de..0e2dc1bffa1aa7f657df1a91639948323a84ed23 100644 GIT binary patch delta 760 zcmXAmSx-|@6otRjmU~Yx*N8|ELLh<2&{7n^d0>(vgA6J-qZC2VT8eE^5fv2`XMyAN zY~r&Kf+Rfn1N;p>`X5Y0i09yWSbOia*Shh3Iu%ywUl&~S2Om@VkS<>RLiB?0lNsda|P2J(w(3z=6 zoiN^R13i-JlMbgiZ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H aAy0Wko|yx)%~p08t~G;gIuj0Ou=5`eu8}1G diff --git a/src/main/java/Tasks.class b/src/main/java/Tasks.class index 2b5bf832f888d253e7cae7253f7d51572884ae32..c840df14a07f9f07845e3de44ebb1e6f4de3a42e 100644 GIT binary patch delta 57 zcmcc4a-C(vJVstN1{MZ(22KVJ20jMP$*UPn7 Date: Thu, 16 Feb 2023 14:29:11 +0800 Subject: [PATCH 08/31] Level-4 In-progress --- src/main/java/Deadline.class | Bin 0 -> 868 bytes src/main/java/Duke.java | 2 +- src/main/java/Event.class | Bin 0 -> 946 bytes src/main/java/Event.java | 15 +++++++++++++++ src/main/java/Tasks.class | Bin 599 -> 1141 bytes src/main/java/ToDo.class | Bin 0 -> 736 bytes src/main/java/ToDo.java | 11 +++++++++++ 7 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/main/java/Deadline.class create mode 100644 src/main/java/Event.class create mode 100644 src/main/java/Event.java create mode 100644 src/main/java/ToDo.class create mode 100644 src/main/java/ToDo.java diff --git a/src/main/java/Deadline.class b/src/main/java/Deadline.class new file mode 100644 index 0000000000000000000000000000000000000000..0b7ede5f53882c891aeeca2f0619fe53335bb33d GIT binary patch literal 868 zcmaJ<+fEZv6kU6enO+781w_1X(E^=ffXV z0}>4h4}O3jW!%$Nt(l1rbI#uTthM%K_K%-;-vPXYSAdPhJZ4c&tfewXR~NC31s{E#C# zqsO|0<*Jt^6ACRoh&u8xNZ@k^QglNWd6CrRB9DhI9OPWgVVZRz(hE^S6jstVf zR&0baEb=NtB;86zcMi6a(zXeezjF@MmF~&OxX1YpMaSr9=wO$p-_*J{=o8!zO3A1Z zia3^B#FyzJCK}@@ycen)%D6Hn*3*?uMgAeShkcm=KbgXR_Ag||)Teu!NHjzkwgMyT z4yuIhRDW5u5!U~Y!xk^A&1=dlmHcyBO%7rZZT8)3hRzD;Q9~OW*p$MLWyq+3#jm&qfgc5Pg%RacW!=(w0&_iVG>kZlM<>1VJ2#S^)}hNK_6LhfT7yZk*l7-bCs@ z;b(xj3p zvT&QQ5E~I0Lb-7wMq)P<>S(uVqCg$h2wADRg#3#@1?DB;Sv5`iAH+K#$^DM&d2flh7ZXL{FdqYR%n{$AGA#CXj##>*G%}}c3zfuil~DQfFo7EBo}9kV#KFGk z7#*Ej@cE${TK9$ng7Zcx8P!7($C7P*nYA_5m|V_lp}L`rE0e-n+Sv^9S7GaPAm`8z zXZRo5C$eK|v%O6v>LLuAfsr)}+k~xDfAhQ%HvY}SCJ(s9qn$x6nF)?^$ykgL;!$xx zSmNx-m;sdh?F*2Jv=p5N^d`7s+Yndy-Y74AqvsRH+cyv*kD)`89#6153Isc67 o&yc-jI==qa$d4II%)G`}hBY7ZZZop1-{5ck7wNO_^8f$< literal 0 HcmV?d00001 diff --git a/src/main/java/Event.java b/src/main/java/Event.java new file mode 100644 index 000000000..c66997208 --- /dev/null +++ b/src/main/java/Event.java @@ -0,0 +1,15 @@ +public class Event extends Tasks { + protected String start; + protected String end; + + public Event(String description, String start, String end) { + super(description); + this.start = start; + this.end = end; + } + + @Override + public String toString() { + return "[E]" + super.toString() + " (from: " + start + " to " + end + ")"; + } +} diff --git a/src/main/java/Tasks.class b/src/main/java/Tasks.class index c840df14a07f9f07845e3de44ebb1e6f4de3a42e..ec090680a6512461b3bf913a0da3deca7f03ef86 100644 GIT binary patch literal 1141 zcmaJx{b7HXbacMi7 zBf^4>MH}}ShH4`6!=R}HB^h$N$NZG9Hn==oE$c9lhed{T5N#G1m*~l}v zCp@fgc1$GlrivFs?_})E(JHn}E~=hUx$FFiW$aq0zUHG*dvkq!|QSQ(!b4S&E}{ zS|f%n`lM`wr5_voAd3r9Qs A{{R30 delta 277 zcmZvUJyHTe6okLo8FrR+kd+^C7m-~G2?!uG)mvy;1fGQQ2wQUmPe5Q|zyVANI0-4m zn~h2O_3Qe&Ps!0d|DXT%zzbE1C2tc`1Q{nhCQK|(mTA5IQDuFY`$!eJW9Ud|J5p{G z`tyAgwA}a)wOUX~*~(&s36wY!z~(9(9Td0zRhO#kzjSUh?waIVm)ovTv3v;E6SYL{ t&C-`>z%XDE&SW|u@zVUFcj6SGm`V;At!D843a_v51L4E+NV+=W;Q}Y!7xn-E diff --git a/src/main/java/ToDo.class b/src/main/java/ToDo.class new file mode 100644 index 0000000000000000000000000000000000000000..c4b1050830cb3c564eaa257b141c02b1b796c088 GIT binary patch literal 736 zcmaJ<%TC)s6g@W(JGgEW-lY$o0r8Mv$-;<5Q=wK$+eNH)5wVy!BQP;Dk!OO$pYR#5 zLSn%O@KK2CIHIW%)snC8J#)@|jh~($9swMp>Y<2tnJLdOFzaH@#XP||idAfn3G>_a z3vne55~0ox8a9p9S+Mh)Fj>=WNhsH2C4crVTQUtrD`BK$bxtG9ZSRbV30_0@(ny}f z8GS0$U-f=g!iNLbhle+W$``Gzv8m|(koH`+P1(Uh35!17V~LArB0@0~rei#Oz(>ZK z;VBUoFGWYzw2FlN6Weq4j1|fn!q&J+M*DN|DXX$dsQw*1R#&#iI_Zw~Q)wJv02 zgW=r|Qq)9}G-4|Q7aN4lk@?2;Mp*to4{Mm@|0jD2;9bCFTjFS);{t!3-MxFz9eaG; zY`s33X^M>SeZTUFJwD&PN8tez!0oHX>7Pt7=rdNpTdedm5k7PMWh|k>afw;e{LZ`p DarU^| literal 0 HcmV?d00001 diff --git a/src/main/java/ToDo.java b/src/main/java/ToDo.java new file mode 100644 index 000000000..cb1d55469 --- /dev/null +++ b/src/main/java/ToDo.java @@ -0,0 +1,11 @@ +public class ToDo extends Tasks { + + public ToDo(String description) { + super(description); + } + + @Override + public String toString() { + return "[T]" + super.toString(); + } +} From fe13d521f2ddd2bc9cdf50ce1107a6271b0aba54 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Fri, 17 Feb 2023 14:16:34 +0800 Subject: [PATCH 09/31] Level-4 --- src/main/java/Deadline.class | Bin 868 -> 867 bytes src/main/java/Deadline.java | 2 +- src/main/java/Duke.class | Bin 2832 -> 3347 bytes src/main/java/Duke.java | 113 ++++++++++++++++---------- src/main/java/Event.class | Bin 946 -> 935 bytes src/main/java/Event.java | 2 +- src/main/java/Tasks.class | Bin 1141 -> 1139 bytes src/main/java/Tasks.java | 2 +- src/main/java/tempCodeRunnerFile.java | 0 9 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 src/main/java/tempCodeRunnerFile.java diff --git a/src/main/java/Deadline.class b/src/main/java/Deadline.class index 0b7ede5f53882c891aeeca2f0619fe53335bb33d..f14fe122d6ac4c753d33392da070f01e58dde3d3 100644 GIT binary patch delta 18 ZcmaFD_LyyhCL=3Xv`Z}GW_?CeCIC0|1k?Zk delta 19 acmaFN_JnPNCLee6SL`qrn+bf%Ae>Qi5Oqy5fG#-eDLuI60#Ki~N; z-~X?E|KQ$l0X&0u3>?IG1QR%`h)RGNS7AJOru!u_a*k7@Y0hSvmYvl-V* zI@gk(<<7eT`lYccH5(GpQcf}F*#!ZS5C|X15$LMOPg(^My>#OIj%}MyGRhH=lf`+vPZ?_BeK@S)lO{fePYY}rwX<2LRVLaOq>_<_ zhR>MzERG7eGRa4lpNA7;S<0lm%*Jt9F8fkR$?ZpeaT!-)YTK78^-><;sbt((R@iZQ zIhpK9^3~-eXUSzlpkdUxAyZaPX5^fm&CB9Z$z8#=Eg|QuMO#|ww4IjTT*j4(D1*|( z(>P>e0MD5C96m2lf5LG**DF~0aod}7(r#TCU(oSI6JNrY{m`Fulp~Iscs~xS*>Tkk z>-dU}uPUjpnK**O^p8)DqL<0WC#h7nl zE!;No1EtfBiA>6Fl~d~ukaR@KS;%K?&rS=po_3rxRq2zXPTrQDBVF5;MQP2FL2|HD z8YX_Ia6*1^Q4JM%I&C8l&dyx7Q&g~GtCSiHPZj<>D!Al&_5uxZibQBEu{Gnw&#CMq zift`0pBwzk9^Gb^`ze|w&vnmPzj13v=i`(&@FV<~woW@mnImC*VhEoPuB4gXoGq1; z`vjU7ta*Fb$)zmsLdKip%=N6C$NJLPk*ESKuxr#VkY=i7v(mXHmzYYjj6Nu7o9Gj& zE+igTtS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!IV&XMBBCvFN+4<0~EE)KSRh#tv#cEl=%Ia1# z?%F}1SgKFzmS) zSYZFA^EJv%V9)=yLk~ZT8GiMEIKONBTyT7btKFR0Adwij5Ag>I0)rfzBV`ONx{*@W zrsMnoYSZp7(3Fm?BA!lMpg2HDYnnN)1MEN|f-(8|-NOExMk{t;bQi-q?;XrGb~MqE z=>8miRCFZb*9SWihgZ?5r$1unLnaGa-A)krFDv+)cHd=uhPkeI%veQt`l;v|rn=&0 zv_;he>>f@Gb|qG^Cte`d(>jzS2)}7uP#hC7j zr;Ps=WSnOY5%qL+p=&4t5{zir>Rd&ar#wyDh|~8(ew(wGN;Q%`2^|?WgEt z= 4 && input.substring(0, 4).equals("mark")) { - Integer index = Integer.valueOf(input.substring(5, input.length())); - list_of_tasks[index - 1].markAsDone(); - System.out.println("Nice! This task is completed"); - System.out - .println(list_of_tasks[index - 1].getStatusIcon() + " " + list_of_tasks[index - 1].description); - } else if (input.length() >= 6 && input.substring(0, 6).equals("unmark")) { - Integer index = Integer.valueOf(input.substring(7, input.length())); - list_of_tasks[index - 1].markAsUnDone(); - System.out.println("Ok, This task is still not complete"); - System.out - .println(list_of_tasks[index - 1].getStatusIcon() + " " + list_of_tasks[index - 1].description); - } else { - System.out.println("added: " + input); - list_of_tasks[counter].description = input; - list_of_tasks[counter].isDone = false; - counter++; + switch (command[0]) { + case "todo": + Todo(command[1]); + break; + case "deadline": + String[] d = command[1].split("/by", 2); + String d_description = d[0]; + String d_by = d[1]; + Deadline(d_description, d_by); + break; + case "event": + String[] e = command[1].split("/", 3); + String e_description = e[0]; + String e_start = e[1]; + String e_end = e[2]; + Event(e_description, e_start, e_end); + break; + case "list": + List(); + break; + case "mark": + Integer m_index = Integer.valueOf(command[1]); + list_of_tasks[m_index - 1].markAsDone(); + System.out.println("Nice! This task is completed"); + System.out.println(list_of_tasks[m_index - 1].toString()); + break; + case "unmark": + Integer u_index = Integer.valueOf(command[1]); + list_of_tasks[u_index - 1].markAsUnDone(); + System.out.println("Nice! This task is completed"); + System.out.println(list_of_tasks[u_index - 1].toString()); + break; + default: + System.out.println("There was an error. Please try again"); + break; } - scan = new Scanner(System.in); input = scan.nextLine(); - + command = input.split(" ", 2); } - System.out.println("Goodbye. Hope to see u again :) \n"); scan.close(); } diff --git a/src/main/java/Event.class b/src/main/java/Event.class index 5c5aaf33fd2d9f002d1b736c3b9e5f60c30f31db..cf9f9d1295bf9489917e67d2a31ff6ad651f0d3b 100644 GIT binary patch delta 20 bcmdnQzMOr72O~R2v}-J*2IJ-^#t0?=J6Qz( delta 31 mcmZ3^zKMN<2cwX1v}-J*f<{_Vey)`Qqe4l(!e)QQ2qplF^axu3 diff --git a/src/main/java/Event.java b/src/main/java/Event.java index c66997208..0f1b289e7 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -10,6 +10,6 @@ public Event(String description, String start, String end) { @Override public String toString() { - return "[E]" + super.toString() + " (from: " + start + " to " + end + ")"; + return "[E]" + super.toString() + "(" + start + end + ")"; } } diff --git a/src/main/java/Tasks.class b/src/main/java/Tasks.class index ec090680a6512461b3bf913a0da3deca7f03ef86..3af8f37b6508f24026022927f3368bb8f56f0e7b 100644 GIT binary patch delta 15 Wcmey$@tI>oA0rbpkC^~4a|LMt delta 17 Ycmey&@s(pkA0rEEG-K@M35<`K06Y!`BLDyZ diff --git a/src/main/java/Tasks.java b/src/main/java/Tasks.java index 34b6f1b70..604767221 100644 --- a/src/main/java/Tasks.java +++ b/src/main/java/Tasks.java @@ -22,7 +22,7 @@ public void markAsUnDone() { @Override public String toString() { - return "[" + getStatusIcon() + "] " + description; + return getStatusIcon() + " " + description; } } diff --git a/src/main/java/tempCodeRunnerFile.java b/src/main/java/tempCodeRunnerFile.java new file mode 100644 index 000000000..e69de29bb From f5259c35454166b3e586cab909cf54610e98b6df Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Fri, 17 Feb 2023 22:49:24 +0800 Subject: [PATCH 10/31] Create Duke.jar --- Duke.jar | Bin 0 -> 4703 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Duke.jar diff --git a/Duke.jar b/Duke.jar new file mode 100644 index 0000000000000000000000000000000000000000..67591a87d9eda8f9d863815a41d7090c2d65ef47 GIT binary patch literal 4703 zcmZ`-2QZx9*A^|xV)ZDIMDK*y2uqY8`mVCkEvp8rw`dWph#C<@5WR*FUG#{J-n-RS z_ghh;B>4Eg-+Ynz&;Pvh&b)WtIrrYV&vVat&Vi^C5Ypk1kdWY2RzYESSBwsi5KmJ{ zPhLn>OIbuyUQ1P3Nmox;Q~9h54{uMir&~i^NO+J!U5LN0r@ul+bVPi9c~`TiXV|k( zRZzHE$Azy~Yk7Hb86OX#ew`%l?kQC0Vse3t7xMp0LY@9zlJes3BWnvQM|-5TFv8Ko z-Q5YQs{U1u?##^ieR3Ym0drUtISqyEWGoi)X3;$YYrL0NLFf$WZJYBI5D^7Ef2ijF z21Yg3jV+lI+dDq^c@0iWL~!?o@9i)wzc%w@;IqC**lPKg`nO0XccW_=SxUD{L0Vts ze4k8*F2(HX)vAAItVd(gEW_d^4sY7uiAkU!09mYk7`Du143%Y(c}yc_4f7ajDDIlq z&@(Okb|kR?dz9gUvFC1c`1Z79HA1CWfZVkvbIt*D#1(Co+JE@sn&FIt6+0@!FcW}aO_Ncbadmk^ZR7mYNMAch17k_(S3V|7|?zIKVAcOJVM>KY#28~m#X;<^2eAlW5? zo(}(_7Y*}sF|npU$5`DzTv^GZuxG9hm`zONbc(OC_q|6N@H#OEBWpJ_P#K2n-E#We zyETiGHNvM>a-gS&_}?ai(wWjLOAB;+P3cwdzD8%WfMp51ngwmCu6sxIZXBhQA5bZ@eSADOyyF#H144La9>Wwp z!HJ!yM(o1JH%y&&qA{T-p&J7kDh(!Ln|Ts;GT^nSc0{LvR|RUfBQG$eaX50wv5L5P zs2~(|%<#JaxIs)V1#nX+&-rpc>4wK}Kp%W&6vDF0uGKK7incPhf_d;yb9X_VGby=o zw&4gs0Xye{IIBA^u71)*7@H?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t&MG8syKEoDDXFaS+o-cDQc-{{m`F+|LbC=ujANB-f)S;RCpWNjTNc3 z8n7R5qV#KA@p-o$aXQY!`-V>S`HUwafuD9CV!Awp2N1UFfz17uA?q&P_WXr!%sqx1 z32wP>i6vGavvZZOh7+gV(XF|;^UP<2VYX>m4VhOrd&8S?)wI1jl61l{D zQh0D5SV>sfnl~kE8O8C)DG(h6D~oY0({=e zo*W*RDr0SVp>rhektbd4dipZxVUlA(n#g|$P54oWdvW%J*2D_wKr(S^7`omJ7;p^x z9Z}^yN{tLe-WHDq>H#A(4oYaEr0*=1aQ0sFE@ST~KY8;A#x1 zgFyZ&u`jD7J?BTx|FSJkQ@c$Lh?)x?8q!e`Fb~|M5bYWyK!q@CM>8_hAi#niA;nc( zxkq32@guk|V~A@FkaCgD#@1%e*T$wfNVW+t75iNdmEk++X(h+81O^4N(e9H|zsgbM z9mnwe>@vDW9$tc^iFBDj?pt;0FS(N&CWG7tNR^(1{`T4(S}jMPT;q{M-h<1>epC1s znUe@6`{u3R4a%I~+qun<{pe99zoEVIcb>r+o`j8P{jgvmg#+gkH+K9FXx{|VNxvVh zF9>ugOe)HQHR-n|CcdS!qN0_-`=t5jLSN#I;-<-<90nLW8mgmc$mYAJCF1(Qi0>T` z9uApfl_6%ajqj2i&W*leif1wbH91v7AGzN?pv!skt{9FG%3U*1fr>qjZnm<{y`CVu zF!LaniNBYrNY_!j{JffTv#>*>@TW<01`Vao=z_>40!qLY6Sa#APyN3a{u(|V-k&zd z)o#RPo8xc$Z%q$~`kz@YI~P|g;>*s(A9KI>{JW2F)%UVyzM5k$S@6dsF82GUg1+i^ znSri`vC9nf$8KE=ujHevj+asHDk1-N+y`8c@K4OU>Uhc5tLOOlP7xRR@eg|;>O{ns QyCJ@KtS-)d8F)GRAC}@X*#H0l literal 0 HcmV?d00001 From dc3b488ba3bf69813858e34b3598fe04922a0f7c Mon Sep 17 00:00:00 2001 From: TzeLoong <75962194+TzeLoong@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:57:37 +0800 Subject: [PATCH 11/31] Delete Duke.jar --- Duke.jar | Bin 4703 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Duke.jar diff --git a/Duke.jar b/Duke.jar deleted file mode 100644 index 67591a87d9eda8f9d863815a41d7090c2d65ef47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4703 zcmZ`-2QZx9*A^|xV)ZDIMDK*y2uqY8`mVCkEvp8rw`dWph#C<@5WR*FUG#{J-n-RS z_ghh;B>4Eg-+Ynz&;Pvh&b)WtIrrYV&vVat&Vi^C5Ypk1kdWY2RzYESSBwsi5KmJ{ zPhLn>OIbuyUQ1P3Nmox;Q~9h54{uMir&~i^NO+J!U5LN0r@ul+bVPi9c~`TiXV|k( zRZzHE$Azy~Yk7Hb86OX#ew`%l?kQC0Vse3t7xMp0LY@9zlJes3BWnvQM|-5TFv8Ko z-Q5YQs{U1u?##^ieR3Ym0drUtISqyEWGoi)X3;$YYrL0NLFf$WZJYBI5D^7Ef2ijF z21Yg3jV+lI+dDq^c@0iWL~!?o@9i)wzc%w@;IqC**lPKg`nO0XccW_=SxUD{L0Vts ze4k8*F2(HX)vAAItVd(gEW_d^4sY7uiAkU!09mYk7`Du143%Y(c}yc_4f7ajDDIlq z&@(Okb|kR?dz9gUvFC1c`1Z79HA1CWfZVkvbIt*D#1(Co+JE@sn&FIt6+0@!FcW}aO_Ncbadmk^ZR7mYNMAch17k_(S3V|7|?zIKVAcOJVM>KY#28~m#X;<^2eAlW5? zo(}(_7Y*}sF|npU$5`DzTv^GZuxG9hm`zONbc(OC_q|6N@H#OEBWpJ_P#K2n-E#We zyETiGHNvM>a-gS&_}?ai(wWjLOAB;+P3cwdzD8%WfMp51ngwmCu6sxIZXBhQA5bZ@eSADOyyF#H144La9>Wwp z!HJ!yM(o1JH%y&&qA{T-p&J7kDh(!Ln|Ts;GT^nSc0{LvR|RUfBQG$eaX50wv5L5P zs2~(|%<#JaxIs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ada206 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Sat, 18 Feb 2023 23:18:18 +0800 Subject: [PATCH 12/31] Handle errors --- src/main/java/Duke.java | 56 ++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 0be2fec87..4af4d2785 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -62,35 +62,55 @@ public static void main(String[] args) { while (!"bye".equals(input)) { switch (command[0]) { case "todo": - Todo(command[1]); + try { + Todo(command[1]); + } catch (ArrayIndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } break; case "deadline": - String[] d = command[1].split("/by", 2); - String d_description = d[0]; - String d_by = d[1]; - Deadline(d_description, d_by); + try { + String[] d = command[1].split("/by", 2); + String d_description = d[0]; + String d_by = d[1]; + Deadline(d_description, d_by); + } catch (ArrayIndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } break; case "event": - String[] e = command[1].split("/", 3); - String e_description = e[0]; - String e_start = e[1]; - String e_end = e[2]; - Event(e_description, e_start, e_end); + try { + String[] e = command[1].split("/", 3); + String e_description = e[0]; + String e_start = e[1]; + String e_end = e[2]; + Event(e_description, e_start, e_end); + } catch (ArrayIndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } break; case "list": List(); break; case "mark": - Integer m_index = Integer.valueOf(command[1]); - list_of_tasks[m_index - 1].markAsDone(); - System.out.println("Nice! This task is completed"); - System.out.println(list_of_tasks[m_index - 1].toString()); + try { + Integer m_index = Integer.valueOf(command[1]); + list_of_tasks[m_index - 1].markAsDone(); + System.out.println("Nice! This task is completed"); + System.out.println(list_of_tasks[m_index - 1].toString()); + } catch (ArrayIndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } break; case "unmark": - Integer u_index = Integer.valueOf(command[1]); - list_of_tasks[u_index - 1].markAsUnDone(); - System.out.println("Nice! This task is completed"); - System.out.println(list_of_tasks[u_index - 1].toString()); + try { + Integer u_index = Integer.valueOf(command[1]); + list_of_tasks[u_index - 1].markAsUnDone(); + System.out.println("Nice! This task is completed"); + System.out.println(list_of_tasks[u_index - 1].toString()); + } catch (ArrayIndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } break; default: System.out.println("There was an error. Please try again"); From 88c26839bf9ab563c273a42d5b3a463497df3cf3 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Sat, 18 Feb 2023 23:48:19 +0800 Subject: [PATCH 13/31] Use of ArrayList --- src/main/java/Duke.class | Bin 3347 -> 4022 bytes src/main/java/Duke.java | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index 1476561c6df1c5521c0762d23b1c7aefbf3036ac..707304b23cefa13c6ea174a643770f766eb9e760 100644 GIT binary patch literal 4022 zcma)8TXYlG72Q{sG^1gt!C=7VHM9mlu&u-pC)nm`19tqRHV*?qjHQb$ENg@`GPpSD zD}B;;`XIDT+N7zQgf;>JM@B`c?(wckc z+&O2TbN8Hc?)>5Q_16GAh&K&1;YbMmII82Af#Y~Y#|a$~9Vd0zAv9t@4N(Kz5Yr$H zm^f8L+tV6`4HP1wo{SjONor^}undldP6NeA6+z&15q!v~$F7E~ax`k76lc|NPRE#m zUVK8wc{Pu#;ZYrr>G-6MPwDuyj?d`$tg?Pw!{>B-UdI=d^hF(CQuCM9aKXS=@KrT@ zO-1*09p6y%H+6hV#}mrYw>5l6g?U87cQt%ZU{NBTal23T*_q*tKyk-ud(;kR-FPCr zJDs-2I{36vAk-TlOxkWXEd|ysq|?;lAvErwvKDo+Nmr%?M4LdcDV~hGI|K?UDh~ zT1CRfxWW!w$0L#I2p=7f@GdfL2rO%L&RS7BX~nG}nMhgLofcOGuT^cemESD+PV42vC9VT{TkBO)8BY}XII3|9KX9Sk)aU3_}rtMUxbcdW+rZ9+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6C{n88(Xwbct$g6-%&9v|zi~fNs%?*iJEsT_TKr zaRdY61P0wnS%9<| listOfTasks = new ArrayList(); private static int counter = 0; public static void greet_user() { @@ -19,28 +20,28 @@ public static void greet_user() { public static void print_action() { System.out.println("\n"); System.out.println("I have added this task: "); - System.out.println(list_of_tasks[counter - 1].toString()); + System.out.println(listOfTasks.get(counter - 1).toString()); System.out.println("You now have " + counter + " tasks in the list."); } public static void Todo(String description) { Tasks t = new ToDo(description); - list_of_tasks[counter] = t; + listOfTasks.add(t); counter++; print_action(); } public static void Deadline(String description, String by) { Deadline d = new Deadline(description, by); - list_of_tasks[counter] = d; + listOfTasks.add(d); counter++; print_action(); } public static void Event(String description, String start, String end) { - Event E = new Event(description, start, end); - list_of_tasks[counter] = E; + Event e = new Event(description, start, end); + listOfTasks.add(e); counter++; print_action(); } @@ -48,7 +49,7 @@ public static void Event(String description, String start, String end) { public static void List() { System.out.println("Here are all of your " + counter + " tasks: "); for (int i = 0; i < counter; i++) { - System.out.println(i + 1 + "." + list_of_tasks[i].toString()); + System.out.println(i + 1 + "." + listOfTasks.get(i).toString()); } } @@ -95,9 +96,9 @@ public static void main(String[] args) { case "mark": try { Integer m_index = Integer.valueOf(command[1]); - list_of_tasks[m_index - 1].markAsDone(); + listOfTasks.get(m_index - 1).markAsDone(); System.out.println("Nice! This task is completed"); - System.out.println(list_of_tasks[m_index - 1].toString()); + System.out.println(listOfTasks.get(m_index - 1).toString()); } catch (ArrayIndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } @@ -105,9 +106,9 @@ public static void main(String[] args) { case "unmark": try { Integer u_index = Integer.valueOf(command[1]); - list_of_tasks[u_index - 1].markAsUnDone(); + listOfTasks.get(u_index - 1).markAsUnDone(); System.out.println("Nice! This task is completed"); - System.out.println(list_of_tasks[u_index - 1].toString()); + System.out.println(listOfTasks.get(u_index - 1).toString()); } catch (ArrayIndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } From 1712749a1dd9e800a9acb1a92d4d13e6d2cedf77 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Sun, 19 Feb 2023 00:02:42 +0800 Subject: [PATCH 14/31] Delete --- src/main/java/Duke.class | Bin 4022 -> 4338 bytes src/main/java/Duke.java | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index 707304b23cefa13c6ea174a643770f766eb9e760..26f908d21cff00e04fade3d3fe16e6608148cd75 100644 GIT binary patch delta 2186 zcma)7Yj9Il5dO~1&Am6bm$rmwT3S+|4`|cUqHPJ3@(8vCTKb|7<S z-c4xiuL=I^56+$kkb~PQW@4!c%TTAlsbV?m6}S|*6|7LO(u908aMGwE4^1+fRcP>- z>1>;fRVt#;&NUq>+4y8ER51*lGRjnpK$jT|ZDt5qtDu{kt>b3T%J4tOBd%9527XR9 zDA=f?7Mm1o=6nk$TNP|muwB9P3U(;iso(_#ySRtlGWIBVQNdo0UQ)1+^8hC=tJsfM zIC+(4dO*QJ&JS_jYYJXh@CF5p#$g$6@{E?scuU6HJrAl_q~vgW+&(vhm{K&cDo`$r z6W@_>B(O$EN-jX5jCVC0#W9AVg>H|>n_w+UZm~K#o84AbMo`0hC<$B^PWfkHwuZTQ zO2hj&&S0!`b~JZrIDwN4(X+i?Ux%;V*;efKHF#YeQ4&rm_&~#lI8Bi&y$-L20+eXz zL9d1dDCDq|lX3-p3O?edXBftoczteHy0ysK;Ouf+U3%^=tFNKBvBT=4kQzcbu3

J0+ z4fxkkOqVPcJ>wUml+I*mC_}l13SORz8a~748ZP02hA&VUxFaSgm-z)2p=zJ8*l>kp zrN&iUh?@8d&@Jzp3fR0rx*8`_1$0Tdnog39B%xa9lA~(IAa4`MUn2QP zB2USbQVMyaV(FIm)X8*qQbe3gmD4395%WlLFe27pNtu`+{E2Ax2OTu=>TweiH$kKw zFrycO*%E?Cycebz(G^0(MQ9-m(S-w&nCf1rqN@+8Zl<0^B&a9E#|4R@k^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o%S!fn2ldfO#*1{5ZX<)^+b!`eKRxho%fU5|;~pEu{WXre zD+T%NY5_YdWOo7FMgcjnkaQH$NEFjp?)4;;QVPmBOc_nV5}JVu%0VT~!!jyB6&0hJ zDo{gpSk5Wb(rVPv2CSfFtfFumR#OMo(q^oqooJv4g4Bmb&T&0=>;^iACc21Lx`H

Date: Mon, 27 Feb 2023 15:04:08 +0800 Subject: [PATCH 15/31] Save --- src/main/java/Duke.class | Bin 4338 -> 5368 bytes src/main/java/Duke.java | 42 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index 26f908d21cff00e04fade3d3fe16e6608148cd75..bba3a61df0e8c64172223cf6515ffc8c9cc4b3f3 100644 GIT binary patch literal 5368 zcma)9349dQ8UMe@Zf3HK1~yy?5(Whlt^|VwNDv7*NJTK z@wT?!;w@E!T3bL(Qqo#mTU)jEzSP>&deFn#+RKXc|7Is-fo*O0?R)Qg^Ih-%eee4o zFMf33832n#b^tBdo`XJIsNtdjcHom5F4k~~hD$YEmV=XUxg4$tU_ExKxH148R|P41 zor>!N$i)rv%clb5xlu)X0D1Vdip~Hg;4?u8To;6bTQuA%*=|#DyNWwB+!??W+@NAt z0Ml@n9PXCGJ#x5L#eFL7*YJRf2LmWdS=b#!79Nu1!*U?gBO3ap**$W2R370mDgL;I z&jpac6B<4*=P$@%uZDdZ_G@@j!&4fb)-a%9PznyI_@agb8ipnHB@JJe^E1-huV{Ey z5?>AAYj{o$Uzex@`cHW~`&M*@;JD9hCwnRNJwHW5%4b%xKaQ7!!>ooVD#OW}+)0Fd-$9 zbRyBxs(9S&Yvfl-f_e|#bwXyF6R~3yYO%vMy(>Qc zL{g_#W0~P76$%t(V96}xukE#Bj=<9YOCqxlpM-~)Halip*BZ0OJ4$wq6}23C<121( z{cDfJ!gZ0TrQ$pEHevQ!lH&JnGs5FdEIucbeih$U@jVJGYvbWu3aA$ho^CW0bsLh$2&nj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`?@os4`V9x>~JM8$|C`XVvGTFBq9d z76nG0QDTgcM`L)+;76%xq?`Dpmvp8~p3``FPUZBK#+J^6gvwx&xUEuIOjLcCta6y9 z1~Xj^r&^UVLzOXGwwtLcnWd&uqpG=G&E*aiXO608u3Eu7wT?OorB)@FukL1n+Q~w- zi$!WTOVu9g)gc;G8_U#LmP@FO>I<6G*Q`(%NVKZ&SgC$ymAcGoBa?ME$>s4m_wtw6edfiq8w#abi+8@2MpG(GwSvx_u>+x~8{10<39*X0zYH76L=M#$HO ueYM@%9w8{5!IUiDE>wd%I4fFr>reQMPo*g?6MU`AH;S#vldH8fSn~&aag^5p diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 22beae8da..80050e2ce 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,8 +1,16 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.FileWriter; + import java.util.ArrayList; +import java.util.NoSuchElementException; import java.util.Scanner; public class Duke { + private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; + private static ArrayList listOfTasks = new ArrayList(); private static int counter = 0; @@ -62,8 +70,34 @@ public static void Delete(int index) { System.out.println("You now have " + counter + " tasks in the list."); } + public static void findFile() { + try { + File file = new File(STORAGE_FILE_NAME); + Scanner scan = new Scanner(file); + while (scan.hasNext()) { + System.out.println(scan.nextLine()); + } + scan.close(); + } catch (FileNotFoundException | NoSuchElementException e) { + System.out.println("Error: File not found. Please try again"); + } + } + + public static void saveFile() { + try { + FileWriter writer = new FileWriter(STORAGE_FILE_NAME); + for (int i = 0; i < listOfTasks.size(); i++) { + writer.write(listOfTasks.get(i).toString() + '\n'); + } + writer.close(); + } catch (IOException e) { + System.out.println("Error: Tasks were not saved. Please try again"); + } + } + public static void main(String[] args) { greet_user(); + findFile(); Scanner scan = new Scanner(System.in); String input = scan.nextLine(); @@ -100,7 +134,11 @@ public static void main(String[] args) { } break; case "list": - List(); + if (listOfTasks.isEmpty()) { + System.out.println("There are no tasks listed currently"); + } else { + List(); + } break; case "mark": try { @@ -138,8 +176,10 @@ public static void main(String[] args) { input = scan.nextLine(); command = input.split(" ", 2); } + System.out.println("Goodbye. Hope to see u again :) \n"); scan.close(); + saveFile(); } } \ No newline at end of file From 3b1d6d4a1e9dcf052022315dcd8c4b0b731691ed Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Mon, 27 Feb 2023 15:24:41 +0800 Subject: [PATCH 16/31] Save --- src/main/java/Duke.class | Bin 5368 -> 5369 bytes src/main/java/Duke.java | 15 ++++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index bba3a61df0e8c64172223cf6515ffc8c9cc4b3f3..006ecfcb9aa1e03100d21d3220da35176a74bd74 100644 GIT binary patch delta 448 zcmXAl%S+T@6o#MoB$JnFDm7`q!d!?K8cQrRg6!r%nzsfr(Ht^#O0$g2%2LxZ5)1lO z7G&PYtRQs6sbx^R{*6Fd1}!Qg`b5s+**v`GocCAm@7(!%UrP45NOvUI9=XsOT#WjP z67zalg8`u!Nr8lxI4Pf4R}sTDuZ@$i!mX>!_r7c>%-%twlgn7oLDD%yCWp!42)j5+ z3FU4=UaG$%tAb=IN#!^Js+>_nJ}1~oEkWwoOW2$8k7m_7>l9mPpullAjqIV>tCq&M=@Tx7Ep@t}vuq3~PWp8sx4l~Gc&IrZX&z6X zd91HI(KnuHnWy^Bn11kFKY5|QjGLdAmcfJ-GHpdnS}{|$pBX#Atc7@O)x5Pj<}Az` lYvi3Z^WNH6unuC@!;?iF6`zHqqY|iKbGC zk%gqcs<1qb4*_-a*!qGzzQ5h{zw@jN`;vK9e`JlfxVEySm;y(m6tbTn2iU?vA{=5D zb?zSaLV>>0dRB3S4KxtuC}qUiMk6~o=HziFo4jn`c4>=KtrT&B?XEjHNe%7P(#CF1 zx%G~Pc<`rXI$1#yKc`tom*d?O)8j^a6{25Z&S^6PDq&D%q_mYGRg=~p&MV5WVq8=` zBWmD+nz^JFGU{YhXBg7}S2V=9E^|#|OlX{|y2+%bxUOk#D9bI)WSG({ca-CKl*ri^mq=iEZSmRr12BcxKf+x4mR-A2Sx?rNwz|jl8mEX044k h*1=orCTD%j*)Z>Hl=n74-X{4#@4qjHe|xde+#i5?V>$o; diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 80050e2ce..e5f373fb0 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -62,9 +62,10 @@ public static void List() { } public static void Delete(int index) { + Tasks currentTask = listOfTasks.get(index - 1); System.out.println("\n"); System.out.println("Noted. I have deleted this task"); - System.out.println(listOfTasks.get(index - 1).toString()); + System.out.println(currentTask.toString()); listOfTasks.remove(index - 1); counter--; System.out.println("You now have " + counter + " tasks in the list."); @@ -108,7 +109,7 @@ public static void main(String[] args) { case "todo": try { Todo(command[1]); - } catch (ArrayIndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } break; @@ -118,7 +119,7 @@ public static void main(String[] args) { String d_description = d[0]; String d_by = d[1]; Deadline(d_description, d_by); - } catch (ArrayIndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } break; @@ -129,7 +130,7 @@ public static void main(String[] args) { String e_start = e[1]; String e_end = e[2]; Event(e_description, e_start, e_end); - } catch (ArrayIndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } break; @@ -146,7 +147,7 @@ public static void main(String[] args) { listOfTasks.get(m_index - 1).markAsDone(); System.out.println("Nice! This task is completed"); System.out.println(listOfTasks.get(m_index - 1).toString()); - } catch (ArrayIndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } break; @@ -156,7 +157,7 @@ public static void main(String[] args) { listOfTasks.get(u_index - 1).markAsUnDone(); System.out.println("Nice! This task is completed"); System.out.println(listOfTasks.get(u_index - 1).toString()); - } catch (ArrayIndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } break; @@ -164,7 +165,7 @@ public static void main(String[] args) { try { Integer d_index = Integer.valueOf(command[1]); Delete(d_index); - } catch (ArrayIndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } break; From 409496bb3ed23287839674532c781fc43c1dcf2d Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Mon, 27 Feb 2023 15:30:49 +0800 Subject: [PATCH 17/31] Level-7 --- src/main/java/Duke.java | 42 +---------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index e5f373fb0..c54b23d65 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,16 +1,8 @@ -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.FileWriter; - import java.util.ArrayList; -import java.util.NoSuchElementException; import java.util.Scanner; public class Duke { - private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; - private static ArrayList listOfTasks = new ArrayList(); private static int counter = 0; @@ -71,34 +63,8 @@ public static void Delete(int index) { System.out.println("You now have " + counter + " tasks in the list."); } - public static void findFile() { - try { - File file = new File(STORAGE_FILE_NAME); - Scanner scan = new Scanner(file); - while (scan.hasNext()) { - System.out.println(scan.nextLine()); - } - scan.close(); - } catch (FileNotFoundException | NoSuchElementException e) { - System.out.println("Error: File not found. Please try again"); - } - } - - public static void saveFile() { - try { - FileWriter writer = new FileWriter(STORAGE_FILE_NAME); - for (int i = 0; i < listOfTasks.size(); i++) { - writer.write(listOfTasks.get(i).toString() + '\n'); - } - writer.close(); - } catch (IOException e) { - System.out.println("Error: Tasks were not saved. Please try again"); - } - } - public static void main(String[] args) { greet_user(); - findFile(); Scanner scan = new Scanner(System.in); String input = scan.nextLine(); @@ -135,11 +101,7 @@ public static void main(String[] args) { } break; case "list": - if (listOfTasks.isEmpty()) { - System.out.println("There are no tasks listed currently"); - } else { - List(); - } + List(); break; case "mark": try { @@ -177,10 +139,8 @@ public static void main(String[] args) { input = scan.nextLine(); command = input.split(" ", 2); } - System.out.println("Goodbye. Hope to see u again :) \n"); scan.close(); - saveFile(); } } \ No newline at end of file From 8c09680b777edada90ca78bd3d85f4a51a04deba Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Tue, 28 Feb 2023 09:45:58 +0800 Subject: [PATCH 18/31] Level-7 --- src/main/java/Duke.java | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index c54b23d65..e5f373fb0 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,8 +1,16 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.FileWriter; + import java.util.ArrayList; +import java.util.NoSuchElementException; import java.util.Scanner; public class Duke { + private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; + private static ArrayList listOfTasks = new ArrayList(); private static int counter = 0; @@ -63,8 +71,34 @@ public static void Delete(int index) { System.out.println("You now have " + counter + " tasks in the list."); } + public static void findFile() { + try { + File file = new File(STORAGE_FILE_NAME); + Scanner scan = new Scanner(file); + while (scan.hasNext()) { + System.out.println(scan.nextLine()); + } + scan.close(); + } catch (FileNotFoundException | NoSuchElementException e) { + System.out.println("Error: File not found. Please try again"); + } + } + + public static void saveFile() { + try { + FileWriter writer = new FileWriter(STORAGE_FILE_NAME); + for (int i = 0; i < listOfTasks.size(); i++) { + writer.write(listOfTasks.get(i).toString() + '\n'); + } + writer.close(); + } catch (IOException e) { + System.out.println("Error: Tasks were not saved. Please try again"); + } + } + public static void main(String[] args) { greet_user(); + findFile(); Scanner scan = new Scanner(System.in); String input = scan.nextLine(); @@ -101,7 +135,11 @@ public static void main(String[] args) { } break; case "list": - List(); + if (listOfTasks.isEmpty()) { + System.out.println("There are no tasks listed currently"); + } else { + List(); + } break; case "mark": try { @@ -139,8 +177,10 @@ public static void main(String[] args) { input = scan.nextLine(); command = input.split(" ", 2); } + System.out.println("Goodbye. Hope to see u again :) \n"); scan.close(); + saveFile(); } } \ No newline at end of file From d44a21d4bdd9ca5fef06a2bfab81b2ee5eaabbb2 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Tue, 28 Feb 2023 14:32:37 +0800 Subject: [PATCH 19/31] Level-9 --- src/main/java/Duke.class | Bin 5369 -> 5773 bytes src/main/java/Duke.java | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/Duke.class b/src/main/java/Duke.class index 006ecfcb9aa1e03100d21d3220da35176a74bd74..0bad933f7ea5d43b88affee3a9c581f8e914a8d2 100644 GIT binary patch delta 2720 zcmai03wTt;75>lc-Mx2j?k1ZJrU@ai#zF`oCI$!?Pz!-I&;SCd5DC>K*(3|e29gaW z3NA=cp4PC4CITXgD@!vyO$> zqGGEK1KV8e`;dxO9SPVWHDR4?cB)veBMA?ysMB!`cDX=!$OVBm4eiqGF%`R2?9oEl zt0N6NR6MR@1olbtge3bVc~ZqwDh_CPT17-h=D-rqxM0B{2@gxcM$c+EBBLJF@SL5~ z>d?`QP7Pf$nQlpr$&EcPV@5UfNOerZaUG#%oRH|Gh8HxvsNs}`mo%K#a7M$+8eWmk zXH~qa;hcu=Nc3F|=Ow=&Nw1FAa8Z))$$Gr5;SI^ZFLghVYS-7_=m+|!$u``o&Uw+;Ln%fg#2M}{uJHw}2P)WC1>4#8ULZCu`H;J0`; ze4COy{&yPQGw?n>;Dt)-r`H>(z%m2B$A<=LP$^-pBmoV7(C|lT`loQa@>R=6cqe>D zx!F~LKO6W9J~r@IyldcZs0=4sTbzGKpN4-(^G^)?lXE#>Ew)_3$Kls)qnBRBVgvue zr-U)Zz6PJ$%OhChbJux;6*c}qwL2)2bo&GD=K7`vcdfrMSm-uTE%RxVq#svgQdbG& zHkc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java/Duke.java +++ b/src/main/java/Duke.java @@ -96,6 +96,23 @@ public static void saveFile() { } } + public static void Find(String keyword) { + if (listOfTasks.isEmpty()) { + System.out.println("There are no tasks listed currently"); + } else { + int index = 1; + for (int i = 0; i < listOfTasks.size(); i++) { + if (listOfTasks.get(i).description.contains(keyword)) { + if (index == 1) { + System.out.println("Here are the matching tasks in your list: "); + } + System.out.println(index + "." + listOfTasks.get(i).toString()); + index++; + } + } + } + } + public static void main(String[] args) { greet_user(); findFile(); @@ -169,7 +186,10 @@ public static void main(String[] args) { System.out.println(":( There is an error (Index is out of bounds/negative)"); } break; - + case "find": + String keyword = command[1]; + Find(keyword); + break; default: System.out.println("There was an error. Please try again"); break; From 1e53d3396159b3c96a6a1a7981ddfda2cae5c35b Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Tue, 28 Feb 2023 15:51:51 +0800 Subject: [PATCH 20/31] Added comments --- src/main/java/Tasks.java | 20 ++++++++++++++++++++ src/main/java/ToDo.java | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/Tasks.java b/src/main/java/Tasks.java index 604767221..00d3a0a82 100644 --- a/src/main/java/Tasks.java +++ b/src/main/java/Tasks.java @@ -3,23 +3,43 @@ public class Tasks { protected String description; protected boolean isDone; + /** + * Constructor for a new Tasks object. Stores a description and status of the + * task. Status of the task is initialised as not done + * + * @param description the description of the new task + */ public Tasks(String description) { this.description = description; this.isDone = false; } + /** + * A string represents the task icon + * + * @return the string representing the task icon + */ public String getStatusIcon() { return (isDone ? "[X]" : "[ ]"); // mark done task with X } + /** + * Set the task status as done + */ public void markAsDone() { this.isDone = true; } + /** + * Set the task status as not done + */ public void markAsUnDone() { this.isDone = false; } + /** + * Returns the task icon and its description + */ @Override public String toString() { return getStatusIcon() + " " + description; diff --git a/src/main/java/ToDo.java b/src/main/java/ToDo.java index cb1d55469..83e3c4ad4 100644 --- a/src/main/java/ToDo.java +++ b/src/main/java/ToDo.java @@ -1,9 +1,17 @@ public class ToDo extends Tasks { + /** + * Creates a new Todo object + * + * @param description the description of the task + */ public ToDo(String description) { super(description); } + /** + * Returns the string corresponding to the task icon and its description + */ @Override public String toString() { return "[T]" + super.toString(); From 2b06b30cdb6ec80300625802e444191940594f64 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Tue, 28 Feb 2023 17:49:54 +0800 Subject: [PATCH 21/31] Added JavaDoc comments --- src/main/java/Deadline.java | 9 +++++++++ src/main/java/Event.java | 15 +++++++++++++++ src/main/java/Tasks.java | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index a062357be..1301fe99f 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -2,11 +2,20 @@ public class Deadline extends Tasks { protected String by; + /** + * Creates a new Deadline object + * + * @param description the description of the task + * @param by the deadline of the task + */ public Deadline(String description, String by) { super(description); this.by = by; } + /** + * Returns the string corresponding to the task icon and its deadline + */ @Override public String toString() { return "[D]" + super.toString() + "(by:" + by + ")"; diff --git a/src/main/java/Event.java b/src/main/java/Event.java index 0f1b289e7..3fd56287a 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -2,12 +2,27 @@ public class Event extends Tasks { protected String start; protected String end; + /** + * Creates a new Event object + * + * @param description the description of the task + * @param start the start time of the event + * @param end the end time of the event + */ public Event(String description, String start, String end) { super(description); this.start = start; this.end = end; } + /** + * Returns the string representation of the Event object + */ + + /** + * Returns the string corresponding to the task icon and the start, end time of + * the event + */ @Override public String toString() { return "[E]" + super.toString() + "(" + start + end + ")"; diff --git a/src/main/java/Tasks.java b/src/main/java/Tasks.java index 00d3a0a82..6b32615aa 100644 --- a/src/main/java/Tasks.java +++ b/src/main/java/Tasks.java @@ -38,7 +38,7 @@ public void markAsUnDone() { } /** - * Returns the task icon and its description + * Returns the string corresponding to the task icon and its description */ @Override public String toString() { From 57076f431df7aac0acf899407996028f2ea5388e Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Wed, 1 Mar 2023 13:40:04 +0800 Subject: [PATCH 22/31] Changes --- src/main/java/{ => duke}/Deadline.class | Bin 867 -> 867 bytes src/main/java/{ => duke}/Deadline.java | 2 ++ src/main/java/{ => duke}/Duke.class | Bin 5773 -> 5773 bytes src/main/java/{ => duke}/Duke.java | 2 ++ src/main/java/{ => duke}/Event.class | Bin src/main/java/{ => duke}/Event.java | 2 ++ src/main/java/{ => duke}/Tasks.class | Bin 1139 -> 1139 bytes src/main/java/{ => duke}/Tasks.java | 2 ++ src/main/java/{ => duke}/ToDo.class | Bin src/main/java/{ => duke}/ToDo.java | 2 ++ .../java/{ => duke}/tempCodeRunnerFile.java | 0 11 files changed, 10 insertions(+) rename src/main/java/{ => duke}/Deadline.class (86%) rename src/main/java/{ => duke}/Deadline.java (97%) rename src/main/java/{ => duke}/Duke.class (78%) rename src/main/java/{ => duke}/Duke.java (99%) rename src/main/java/{ => duke}/Event.class (100%) rename src/main/java/{ => duke}/Event.java (97%) rename src/main/java/{ => duke}/Tasks.class (79%) rename src/main/java/{ => duke}/Tasks.java (98%) rename src/main/java/{ => duke}/ToDo.class (100%) rename src/main/java/{ => duke}/ToDo.java (96%) rename src/main/java/{ => duke}/tempCodeRunnerFile.java (100%) diff --git a/src/main/java/Deadline.class b/src/main/java/duke/Deadline.class similarity index 86% rename from src/main/java/Deadline.class rename to src/main/java/duke/Deadline.class index f14fe122d6ac4c753d33392da070f01e58dde3d3..23d61123177715af60cccb67cfbd02e5f48f8e32 100644 GIT binary patch delta 27 icmaFN_LyzMKPFBd237`M1}+A^$?VL=jG~jRnKb}p5e1tbdHECk=HA)P**Uwe>vLZx91I6X{zOTn`x~{|i)A8Hi6nt3%&?W{ za{c9Avc1kCz-;C-hb-p0et*6$ zrPvr7Ev>{Dn@q8pG`1SG%&1!|f13*h!YMmVRZct=EV46`N~79?_Ycm`*Z=LCDsOH${b1%Wyd;%XQnLvXTKV_EFR;I~DI3ww_ zNH*sshqIE$IVqr3inu7Hw8?fZ$u8QZiYsz}%ThyF>gkZ=E zNp)d=y_aU&g#=l|QqsvM!wvdNy~WI837+jzSjGY}-9LYsmrX1ob1ygd3ew1NRe^FZ z&oWn8az67Zu&hG&AkgH62~fg3R+DS9h&9fO?@C*TpHdPjGk3YAuV*C{6tltJMmHMY zo?dB;DofjBjA~QVki`}wZZ={qg=}?2!AN?YskW0uJ=r#MX*BXq%V{Fa4kPSxzk81F34&&npGdOC+JI!*;%5>QY-IBv` zDd40O(<>#MkTOn51!tv(bFz&-Y2>^#6Ok7BrHu>H!9_VlRC>51r*YEHWr=b{Zg5R* zGaz@lDnneCQEtivw`7Vt@}Y-&@`;Bs%_I5AWBJXX!if49(in!-&!`3&(`24#7Ed*g zajj%Rt9hn1Jl8s2Xakel%uC(J8$G})?clX`@>aW;(q7)_8QyCjA2rHn9pH=J=c|tJ YO~?4IzHz4AkHqenfPHSft4#|32NwHwW&i*H diff --git a/src/main/java/Duke.java b/src/main/java/duke/Duke.java similarity index 99% rename from src/main/java/Duke.java rename to src/main/java/duke/Duke.java index 07e15d754..b399176bf 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,3 +1,5 @@ +package duke; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; diff --git a/src/main/java/Event.class b/src/main/java/duke/Event.class similarity index 100% rename from src/main/java/Event.class rename to src/main/java/duke/Event.class diff --git a/src/main/java/Event.java b/src/main/java/duke/Event.java similarity index 97% rename from src/main/java/Event.java rename to src/main/java/duke/Event.java index 3fd56287a..acc8223d8 100644 --- a/src/main/java/Event.java +++ b/src/main/java/duke/Event.java @@ -1,3 +1,5 @@ +package duke; + public class Event extends Tasks { protected String start; protected String end; diff --git a/src/main/java/Tasks.class b/src/main/java/duke/Tasks.class similarity index 79% rename from src/main/java/Tasks.class rename to src/main/java/duke/Tasks.class index 3af8f37b6508f24026022927f3368bb8f56f0e7b..f0dd5548ff4d854f6c78cd1a2c4c8c4bc9a1baa9 100644 GIT binary patch delta 57 zcmey&@tI>o1~V@Y0}BH$11AF?5b{qhWj0|HpS+6Mf>n-zl|g>;b7pN;RUk`kvN($| KqwZvH77YMMR0^B` delta 57 zcmey&@tI>o1~V@k0}BH?11AFq10MtD Date: Wed, 1 Mar 2023 14:27:27 +0800 Subject: [PATCH 23/31] Changes --- src/main/java/duke/Duke.java | 32 +++++++-------------- src/main/java/duke/Ui.class | Bin 0 -> 577 bytes src/main/java/duke/Ui.java | 16 +++++++++++ src/main/java/duke/tempCodeRunnerFile.java | 0 4 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 src/main/java/duke/Ui.class create mode 100644 src/main/java/duke/Ui.java delete mode 100644 src/main/java/duke/tempCodeRunnerFile.java diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index b399176bf..60216aafd 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -16,17 +16,6 @@ public class Duke { private static ArrayList listOfTasks = new ArrayList(); private static int counter = 0; - public static void greet_user() { - System.out.println("Hello! I'm Duke \n"); - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println(logo); - System.out.println("How can i help u? \n"); - } - public static void print_action() { System.out.println("\n"); System.out.println("I have added this task: "); @@ -36,10 +25,14 @@ public static void print_action() { } public static void Todo(String description) { - Tasks t = new ToDo(description); - listOfTasks.add(t); - counter++; - print_action(); + try { + Tasks t = new ToDo(description); + listOfTasks.add(t); + counter++; + print_action(); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } } public static void Deadline(String description, String by) { @@ -116,7 +109,8 @@ public static void Find(String keyword) { } public static void main(String[] args) { - greet_user(); + Ui ui = new Ui(); + ui.greet_user(); findFile(); Scanner scan = new Scanner(System.in); @@ -126,11 +120,7 @@ public static void main(String[] args) { while (!"bye".equals(input)) { switch (command[0]) { case "todo": - try { - Todo(command[1]); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } + Todo(command[1]); break; case "deadline": try { diff --git a/src/main/java/duke/Ui.class b/src/main/java/duke/Ui.class new file mode 100644 index 0000000000000000000000000000000000000000..1293040fc4fb91a9b66a276d4809dd8a82c6bab4 GIT binary patch literal 577 zcmZuuO;6iE5Ph4F*qD@$@X;1Z8BTmv^^pUpJy0PkMJ-Yar${R&tipn0Bgbx4$$zRG zK;qCJ&>vOxt*Jmr%*r#fZ{ECF@BaCF_Zz@2B!G|ENz9?`V?MwF7JV%Fcr`RlAU!h*GaZ|lFU6>DvTsp8CK3!YV{%=LO~y?(EwX_*w65Zv*!LIF z_o#(Q1Rj=KSiu{Gxg!(D>AHO07|EyN(g0;udYYLo1BLmc^oI|XC@l$amF(+XIwc_oUm{6 zzOkCZE}IPZwob7QkMHEH2IcONeu}$QM#b3JzJ>b5M4?6BtiU?`iwEifTWhSXT%*>m l-(aHM=rG-3=8z`iqregxm5k51Q Date: Wed, 1 Mar 2023 15:10:32 +0800 Subject: [PATCH 24/31] Changes --- src/main/java/duke/Duke.java | 172 ++++--------------------------- src/main/java/duke/Tasklist.java | 148 ++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 152 deletions(-) create mode 100644 src/main/java/duke/Tasklist.java diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 60216aafd..6b6530a8c 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,117 +1,13 @@ package duke; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.FileWriter; - -import java.util.ArrayList; -import java.util.NoSuchElementException; import java.util.Scanner; public class Duke { - private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; - - private static ArrayList listOfTasks = new ArrayList(); - private static int counter = 0; - - public static void print_action() { - System.out.println("\n"); - System.out.println("I have added this task: "); - System.out.println(listOfTasks.get(counter - 1).toString()); - - System.out.println("You now have " + counter + " tasks in the list."); - } - - public static void Todo(String description) { - try { - Tasks t = new ToDo(description); - listOfTasks.add(t); - counter++; - print_action(); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } - } - - public static void Deadline(String description, String by) { - Deadline d = new Deadline(description, by); - listOfTasks.add(d); - counter++; - print_action(); - } - - public static void Event(String description, String start, String end) { - Event e = new Event(description, start, end); - listOfTasks.add(e); - counter++; - print_action(); - } - - public static void List() { - System.out.println("Here are all of your " + counter + " tasks: "); - for (int i = 0; i < counter; i++) { - System.out.println(i + 1 + "." + listOfTasks.get(i).toString()); - } - } - - public static void Delete(int index) { - Tasks currentTask = listOfTasks.get(index - 1); - System.out.println("\n"); - System.out.println("Noted. I have deleted this task"); - System.out.println(currentTask.toString()); - listOfTasks.remove(index - 1); - counter--; - System.out.println("You now have " + counter + " tasks in the list."); - } - - public static void findFile() { - try { - File file = new File(STORAGE_FILE_NAME); - Scanner scan = new Scanner(file); - while (scan.hasNext()) { - System.out.println(scan.nextLine()); - } - scan.close(); - } catch (FileNotFoundException | NoSuchElementException e) { - System.out.println("Error: File not found. Please try again"); - } - } - - public static void saveFile() { - try { - FileWriter writer = new FileWriter(STORAGE_FILE_NAME); - for (int i = 0; i < listOfTasks.size(); i++) { - writer.write(listOfTasks.get(i).toString() + '\n'); - } - writer.close(); - } catch (IOException e) { - System.out.println("Error: Tasks were not saved. Please try again"); - } - } - - public static void Find(String keyword) { - if (listOfTasks.isEmpty()) { - System.out.println("There are no tasks listed currently"); - } else { - int index = 1; - for (int i = 0; i < listOfTasks.size(); i++) { - if (listOfTasks.get(i).description.contains(keyword)) { - if (index == 1) { - System.out.println("Here are the matching tasks in your list: "); - } - System.out.println(index + "." + listOfTasks.get(i).toString()); - index++; - } - } - } - } - public static void main(String[] args) { Ui ui = new Ui(); ui.greet_user(); - findFile(); + Tasklist.findFile(); Scanner scan = new Scanner(System.in); String input = scan.nextLine(); @@ -120,67 +16,39 @@ public static void main(String[] args) { while (!"bye".equals(input)) { switch (command[0]) { case "todo": - Todo(command[1]); + Tasklist.Todo(command[1]); break; case "deadline": - try { - String[] d = command[1].split("/by", 2); - String d_description = d[0]; - String d_by = d[1]; - Deadline(d_description, d_by); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } + String[] d = command[1].split("/by", 2); + String d_description = d[0]; + String d_by = d[1]; + Tasklist.deadline(d_description, d_by); break; case "event": - try { - String[] e = command[1].split("/", 3); - String e_description = e[0]; - String e_start = e[1]; - String e_end = e[2]; - Event(e_description, e_start, e_end); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } + String[] er = command[1].split("/", 3); + String e_description = er[0]; + String e_start = er[1]; + String e_end = er[2]; + Tasklist.event(e_description, e_start, e_end); break; case "list": - if (listOfTasks.isEmpty()) { - System.out.println("There are no tasks listed currently"); - } else { - List(); - } + Tasklist.list(); break; case "mark": - try { - Integer m_index = Integer.valueOf(command[1]); - listOfTasks.get(m_index - 1).markAsDone(); - System.out.println("Nice! This task is completed"); - System.out.println(listOfTasks.get(m_index - 1).toString()); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } + Integer m_index = Integer.valueOf(command[1]); + Tasklist.markTask(m_index); break; case "unmark": - try { - Integer u_index = Integer.valueOf(command[1]); - listOfTasks.get(u_index - 1).markAsUnDone(); - System.out.println("Nice! This task is completed"); - System.out.println(listOfTasks.get(u_index - 1).toString()); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } + Integer u_index = Integer.valueOf(command[1]); + Tasklist.unmarkTask(u_index); break; case "delete": - try { - Integer d_index = Integer.valueOf(command[1]); - Delete(d_index); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } + Integer d_index = Integer.valueOf(command[1]); + Tasklist.delete(d_index); break; case "find": String keyword = command[1]; - Find(keyword); + Tasklist.find(keyword); break; default: System.out.println("There was an error. Please try again"); @@ -192,7 +60,7 @@ public static void main(String[] args) { System.out.println("Goodbye. Hope to see u again :) \n"); scan.close(); - saveFile(); + Tasklist.saveFile(); } } \ No newline at end of file diff --git a/src/main/java/duke/Tasklist.java b/src/main/java/duke/Tasklist.java new file mode 100644 index 000000000..2e79191db --- /dev/null +++ b/src/main/java/duke/Tasklist.java @@ -0,0 +1,148 @@ +package duke; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.FileWriter; + +import java.util.ArrayList; +import java.util.NoSuchElementException; +import java.util.Scanner; + +public class Tasklist { + + private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; + + private static ArrayList listOfTasks = new ArrayList(); + private static int counter = 0; + + public static void print_action() { + System.out.println("\n"); + System.out.println("I have added this task: "); + System.out.println(listOfTasks.get(counter - 1).toString()); + + System.out.println("You now have " + counter + " tasks in the list."); + } + + public static void Todo(String description) { + try { + Tasks t = new ToDo(description); + listOfTasks.add(t); + counter++; + print_action(); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + public static void deadline(String description, String by) { + try { + Deadline d = new Deadline(description, by); + listOfTasks.add(d); + counter++; + Tasklist.print_action(); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + public static void event(String description, String start, String end) { + try { + Event e = new Event(description, start, end); + listOfTasks.add(e); + counter++; + Tasklist.print_action(); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + + } + + public static void list() { + if (listOfTasks.isEmpty()) { + System.out.println("There are no tasks listed currently"); + } else { + System.out.println("Here are all of your " + counter + " tasks: "); + for (int i = 0; i < counter; i++) { + System.out.println(i + 1 + "." + listOfTasks.get(i).toString()); + } + } + } + + public static void delete(int index) { + try { + Tasks currentTask = listOfTasks.get(index - 1); + System.out.println("\n"); + System.out.println("Noted. I have deleted this task"); + System.out.println(currentTask.toString()); + listOfTasks.remove(index - 1); + counter--; + System.out.println("You now have " + counter + " tasks in the list."); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + public static void findFile() { + try { + File file = new File(STORAGE_FILE_NAME); + Scanner scan = new Scanner(file); + while (scan.hasNext()) { + System.out.println(scan.nextLine()); + } + scan.close(); + } catch (FileNotFoundException | NoSuchElementException e) { + System.out.println("Error: File not found. Please try again"); + } + } + + public static void saveFile() { + try { + FileWriter writer = new FileWriter(STORAGE_FILE_NAME); + for (int i = 0; i < listOfTasks.size(); i++) { + writer.write(listOfTasks.get(i).toString() + '\n'); + } + writer.close(); + } catch (IOException e) { + System.out.println("Error: Tasks were not saved. Please try again"); + } + } + + public static void find(String keyword) { + if (listOfTasks.isEmpty()) { + System.out.println("There are no tasks listed currently"); + } else { + int index = 1; + for (int i = 0; i < listOfTasks.size(); i++) { + if (listOfTasks.get(i).description.contains(keyword)) { + if (index == 1) { + System.out.println("Here are the matching tasks in your list: "); + } + System.out.println(index + "." + listOfTasks.get(i).toString()); + index++; + } + } + } + } + + public static void markTask(int index) { + try { + listOfTasks.get(index - 1).markAsDone(); + System.out.println("Nice! This task is completed"); + System.out.println(listOfTasks.get(index - 1).toString()); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + public static void unmarkTask(int index) { + try { + listOfTasks.get(index - 1).markAsUnDone(); + System.out.println("Nice! This task is completed"); + System.out.println(listOfTasks.get(index - 1).toString()); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + +} \ No newline at end of file From 6df5295b4c4b0a628b5ac22a05c276bde3bd25c1 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Thu, 2 Mar 2023 15:13:54 +0800 Subject: [PATCH 25/31] Changes --- src/main/java/duke/Duke.java | 16 +++++----------- src/main/java/duke/Parser.java | 16 ++++++++++++++++ src/main/java/duke/Tasklist.java | 2 +- src/main/java/duke/Ui.java | 4 ++++ 4 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 src/main/java/duke/Parser.java diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 6b6530a8c..77ddb8894 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -1,7 +1,5 @@ package duke; -import java.util.Scanner; - public class Duke { public static void main(String[] args) { @@ -9,14 +7,12 @@ public static void main(String[] args) { ui.greet_user(); Tasklist.findFile(); - Scanner scan = new Scanner(System.in); - String input = scan.nextLine(); - String[] command = input.split(" ", 2); + String[] command = Parser.getCommand(); - while (!"bye".equals(input)) { + while (!"bye".equals(command[0])) { switch (command[0]) { case "todo": - Tasklist.Todo(command[1]); + Tasklist.todo(command[1]); break; case "deadline": String[] d = command[1].split("/by", 2); @@ -54,12 +50,10 @@ public static void main(String[] args) { System.out.println("There was an error. Please try again"); break; } - input = scan.nextLine(); - command = input.split(" ", 2); + command = Parser.getCommand(); } - System.out.println("Goodbye. Hope to see u again :) \n"); - scan.close(); + ui.goodbye_user(); Tasklist.saveFile(); } diff --git a/src/main/java/duke/Parser.java b/src/main/java/duke/Parser.java new file mode 100644 index 000000000..050710abe --- /dev/null +++ b/src/main/java/duke/Parser.java @@ -0,0 +1,16 @@ +package duke; + +import java.util.Scanner; + +public class Parser { + private static Scanner scan = new Scanner(System.in); + private static String input; + private static String[] command; + + public static String[] getCommand() { + input = scan.nextLine(); + command = input.split(" ", 2); + return command; + } + +} diff --git a/src/main/java/duke/Tasklist.java b/src/main/java/duke/Tasklist.java index 2e79191db..b3cfefdfc 100644 --- a/src/main/java/duke/Tasklist.java +++ b/src/main/java/duke/Tasklist.java @@ -24,7 +24,7 @@ public static void print_action() { System.out.println("You now have " + counter + " tasks in the list."); } - public static void Todo(String description) { + public static void todo(String description) { try { Tasks t = new ToDo(description); listOfTasks.add(t); diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java index b1b21cc9d..5439c99b8 100644 --- a/src/main/java/duke/Ui.java +++ b/src/main/java/duke/Ui.java @@ -13,4 +13,8 @@ public void greet_user() { System.out.println("How can i help u? \n"); } + public void goodbye_user() { + System.out.println("Goodbye. Hope to see u again :) \n"); + } + } From 212cf9966ed9ee4299da16159b95be23152f55d1 Mon Sep 17 00:00:00 2001 From: TzeLoong <75962194+TzeLoong@users.noreply.github.com> Date: Fri, 3 Mar 2023 23:20:01 +0800 Subject: [PATCH 26/31] Updated userguide --- docs/README.md | 190 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 181 insertions(+), 9 deletions(-) diff --git a/docs/README.md b/docs/README.md index 8077118eb..80458377e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,201 @@ # User Guide +Duke is a command-line (CLI) chatbot application that helps you keep track of your tasks. + ## Features -### Feature-ABC +### Adding tasks to your list + +You can add three different types of tasks: +1. todo +2. deadline +3. event + +### Printing your list of tasks + +You can view the tasks listed currently + +### Mark your tasks + +You can mark/unmark your tasks if you have completed/yet to complete them. + +### Find tasks by keyword -Description of the feature. +You can find tasks that matches a specific keyword in your list -### Feature-XYZ +### Delete your tasks -Description of the feature. +You can delete specific tasks from the list + +### Save your tasks + +Your tasks are saved after you exit the program and loaded once you reopen ## Usage -### `Keyword` - Describe action +### `list` - Displaying the current list of tasks + +Prints out the tasks in the list + +Example of usage: + +`list` + +Expected outcome: + +Duke will acknowledge and display the updated list + +``` +Here are all of your 3 tasks: +1.[T][ ] run +2.[D][ ] eat (by: 14 July 2023 6pm) +3.[E][ ] sleep ( from 1 June to 2 June) +``` + +### `todo` - Adds a new task of type: Todo + +Adds a new task and updates the current number of tasks in the list + +Example of usage: + +`todo {description}` + e.g. {todo read} + +Expected outcome: + +Duke will acknowledge the added task and display the updated number of tasks + +``` +I have added this task: +[T][ ] read +You now have 4 tasks in the list. +``` + +### `deadline` - Adds a new task of type: deadline + +Adds a new task with a deadline and updates the current number of tasks in the list + +Example of usage: + +`deadline {description /by deadline}` +e.g. {deadline eat /by 14 July 2023 6pm} + +Expected outcome: + +Duke will acknowledge the added task and display the updated number of tasks + +``` +I have added this task: +[D][ ] eat (by: 14 July 2023 6pm) +You now have 5 tasks in the list. +``` + +### `event` - Adds a new task of type: event + +Adds a new task regarding an event and updates the current number of tasks in the list + +Example of usage: + +`event {description /from date /to date}` +e.g. {event sleep /from 1 June /to 2 June} + +Expected outcome: + +Duke will acknowledge the added task and display the updated number of tasks + +``` +I have added this task: +[E][ ] sleep ( from 1 June to 2 June) +You now have 6 tasks in the list. +``` + +### `mark` - Mark a specific task by index + +Marks a task according to its index in the list + +Example of usage: + +`mark {index}` + +Expected outcome: + +Duke will acknowledge and display the marked task + +``` +Nice! This task is completed +[D][X] eat (by: 14 July 2023 6pm) +``` + +### `unmark` - Unmarks a specific task by index -Describe the action and its outcome. +Unmarks a task according to its index in the list Example of usage: -`keyword (optional arguments)` +`unmark {index}` Expected outcome: -Description of the outcome. +Duke will acknowledge and display the unmarked task ``` -expected output +Alright, this task has yet to be complete +[D][ ] eat (by: 14 July 2023 6pm) ``` + +### `delete` - Deletes a specific task by index + +Deletes a task according to its index in the list + +Example of usage: + +`delete {index}` + +Expected outcome: + +Duke will acknowledge, delete the unmarked task and display the updated number of tasks + +``` +Noted. I have deleted this task +[D][ ] eat (by: 14 July 2023 6pm) +You now have 1 tasks in the list. +``` + + +### `find` - Deletes a specific task by index + +Find tasks that matches a specific keyword in your list + +Example of usage: + +`find {keyword}` + +Expected outcome: + +Duke will acknowledge, search for the related tasks and display accordingly + +``` +Here are the matching tasks in your list: +1.[D][ ] eat (by: 14 July 2023 6pm) +2.[T][ ] eat +``` + +### `bye` - Exits the application + +Quits the program + +Example of usage: + +`bye` + +Expected outcome: + +Duke will greet you farewell + +``` +Goodbye. Hope to see u again :) +``` + + + + From 7e9c93f84a2c726e08b3fd78df6ea40a705cee44 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Fri, 3 Mar 2023 23:20:34 +0800 Subject: [PATCH 27/31] Update Tasklist.java --- src/main/java/duke/Tasklist.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/duke/Tasklist.java b/src/main/java/duke/Tasklist.java index b3cfefdfc..0c9fd5e83 100644 --- a/src/main/java/duke/Tasklist.java +++ b/src/main/java/duke/Tasklist.java @@ -138,7 +138,7 @@ public static void markTask(int index) { public static void unmarkTask(int index) { try { listOfTasks.get(index - 1).markAsUnDone(); - System.out.println("Nice! This task is completed"); + System.out.println("Alright, this task has yet to be complete"); System.out.println(listOfTasks.get(index - 1).toString()); } catch (IndexOutOfBoundsException e) { System.out.println(":( There is an error (Index is out of bounds/negative)"); From 6009396576dc91d008f80ada6c8dd636b6d0f22d Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Fri, 3 Mar 2023 23:55:54 +0800 Subject: [PATCH 28/31] Added comments --- src/main/java/duke/Duke.java | 2 +- src/main/java/duke/Storage.java | 26 +++++++++++++++ src/main/java/duke/Tasklist.java | 57 +++++++++++++++----------------- src/main/java/duke/Ui.java | 6 ++++ 4 files changed, 60 insertions(+), 31 deletions(-) create mode 100644 src/main/java/duke/Storage.java diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 77ddb8894..f9a77412d 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -5,7 +5,7 @@ public class Duke { public static void main(String[] args) { Ui ui = new Ui(); ui.greet_user(); - Tasklist.findFile(); + Storage.findFile(); String[] command = Parser.getCommand(); diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java new file mode 100644 index 000000000..0c3c1da39 --- /dev/null +++ b/src/main/java/duke/Storage.java @@ -0,0 +1,26 @@ +package duke; + +import java.io.File; +import java.io.FileNotFoundException; + +import java.util.NoSuchElementException; +import java.util.Scanner; + +public class Storage { + + private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; + + public static void findFile() { + try { + File file = new File(STORAGE_FILE_NAME); + Scanner scan = new Scanner(file); + while (scan.hasNext()) { + System.out.println(scan.nextLine()); + } + scan.close(); + } catch (FileNotFoundException | NoSuchElementException e) { + System.out.println("Error: File not found. Please try again"); + } + } + +} diff --git a/src/main/java/duke/Tasklist.java b/src/main/java/duke/Tasklist.java index 0c9fd5e83..c1d02e718 100644 --- a/src/main/java/duke/Tasklist.java +++ b/src/main/java/duke/Tasklist.java @@ -1,16 +1,11 @@ package duke; -import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.FileWriter; import java.util.ArrayList; -import java.util.NoSuchElementException; -import java.util.Scanner; public class Tasklist { - private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; private static ArrayList listOfTasks = new ArrayList(); @@ -58,6 +53,9 @@ public static void event(String description, String start, String end) { } + /** + * Prints out the tasks in the list + */ public static void list() { if (listOfTasks.isEmpty()) { System.out.println("There are no tasks listed currently"); @@ -69,6 +67,12 @@ public static void list() { } } + /** + * Deletes a task according to its index in the list + * + * @param index The index of the task. + * @throws IndexOutOfBoundsException If index provided is not within the list + */ public static void delete(int index) { try { Tasks currentTask = listOfTasks.get(index - 1); @@ -83,31 +87,12 @@ public static void delete(int index) { } } - public static void findFile() { - try { - File file = new File(STORAGE_FILE_NAME); - Scanner scan = new Scanner(file); - while (scan.hasNext()) { - System.out.println(scan.nextLine()); - } - scan.close(); - } catch (FileNotFoundException | NoSuchElementException e) { - System.out.println("Error: File not found. Please try again"); - } - } - - public static void saveFile() { - try { - FileWriter writer = new FileWriter(STORAGE_FILE_NAME); - for (int i = 0; i < listOfTasks.size(); i++) { - writer.write(listOfTasks.get(i).toString() + '\n'); - } - writer.close(); - } catch (IOException e) { - System.out.println("Error: Tasks were not saved. Please try again"); - } - } - + /** + * Find tasks that matches a specific keyword in you + * + * @param keyword The keyword of the t + * + */ public static void find(String keyword) { if (listOfTasks.isEmpty()) { System.out.println("There are no tasks listed currently"); @@ -145,4 +130,16 @@ public static void unmarkTask(int index) { } } + public static void saveFile() { + try { + FileWriter writer = new FileWriter(STORAGE_FILE_NAME); + for (int i = 0; i < listOfTasks.size(); i++) { + writer.write(listOfTasks.get(i).toString() + '\n'); + } + writer.close(); + } catch (IOException e) { + System.out.println("Error: Tasks were not saved. Please try again"); + } + } + } \ No newline at end of file diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java index 5439c99b8..08f7ca348 100644 --- a/src/main/java/duke/Ui.java +++ b/src/main/java/duke/Ui.java @@ -2,6 +2,9 @@ public class Ui { + /** + * Prints a welcome message + */ public void greet_user() { System.out.println("Hello! I'm Duke \n"); String logo = " ____ _ \n" @@ -13,6 +16,9 @@ public void greet_user() { System.out.println("How can i help u? \n"); } + /** + * Prints an exit message + */ public void goodbye_user() { System.out.println("Goodbye. Hope to see u again :) \n"); } From da04bb5b05883785a1f8d4d8693ac771bcfe95a6 Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Sat, 4 Mar 2023 00:02:55 +0800 Subject: [PATCH 29/31] Create ip.jar --- ip.jar | Bin 0 -> 8502 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ip.jar diff --git a/ip.jar b/ip.jar new file mode 100644 index 0000000000000000000000000000000000000000..f695de9e42a93229df5a6b0a35ca9d654700a9f9 GIT binary patch literal 8502 zcmZ`;1yCH_(#3-;Zi~CyBEccS-CcuAfZ&$kvN!~Hcb6o%F9e5R!GgPlKp?pM@W~5# zf4!dCs@a<9duMLQjky=VUbakWK$4Pl#!HB zQ)g9>yc>jqI#C!Nl9yv)9Y>X8VH_PE`=AP%;#}GMsW3b|={hRI%v!H1%`l=k?F^08 zs^6*)r7ZUhu{X&$4)ieo<4^fvR%9qBM5zBaEBwP%GgljPw#Qrkey~kj<3An@``=r{ z&5g}$t>2iln%WvWJKL$u$wFS@2sKpF7Fn0OmR`4ibluI*SqltT$_rJ+I5wUK@Ds+z z6$SVf=HTJnK)sM{jn@=mf=zD8avsZ!8Jls3+V3X{#Z*;XmrOb?uqZ0DjP6DAgZ%wu>@)hnI9XQ#(?`D*(s;-N-a%lFcE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w9(Ln#c{1ptQ{9hh3UcdL^%(c7$ok zqBu!W?45eHk)uhiNtO|yKL489>~E@UT9TL>DIA`sSSH6W*7B7em{0@BEK%*lkSQzxW@D4t4mE4i! z?l0=7KB)gd>46j=|ARXEZ&?TRUs6EB`d`{;;mzbr459RbUo`$)3<`2X=8#IHoU2-_ z(iLbpkvb>_yDZAe471HQj;*n#fsC8QE6~)W7f`~;?EB)mm=%Rh8JT>}f@jssFMMEl zC5J@)y9h1G3f+sC6M*%s0ZRV(@QyoeWQP4JgEgLcCW*q9^!4-J;0ZaQB-U^T#@S9< zv1zSZuVe)<2Olap)~w|EEspptxeD#8fWlM#5g@TIUln8p9F|bpZ^7YM6Wkm;pBAvR z$($IET<;iIv>(}XaB=x*Vktzt*P2bi4759I1)6H+2zQC^5Xv~x;tFhGJ*%-_rG=dN zHZ$^evb?=5_0LOb)VoWZW9Tw2UTkm-G5!os(k@uunVD|(9@b=Z+cOb#G{5dRmO#K; zt*bq%R3hhb_>Ifci@ZloLA|7wN~|m={iu{;@NGg6CO4%f}(Xyx?-m-`pIiiYuAHF_Q2 z)h>c41HaMSC)bJK_`#;vag>!z`qsth3g^}4=tR>`Dqx>GnV)MxqDwy`Is$$LK7Y+) zzf7~&#uT2JxF+Sfxk~m}JlGF8VQ(JNhV`#c7#ao#>bLCtR2qJio&U7|B|0b^W&WVKKWzHKPAf_;pewmK71a3 z5AYvd^QrSApZ=7DedN=B8|g!p{mc0YyZ+Ssk*Ix2&OH*fzYX?bP5yq}C$#NT_rDmt zCk)3UgZJAQ0ROoE!RI~of8;@)HUoby9o54^{5AcbtjN;=9(#tTnEvP6^8%j?@J|Qv z)cXeL{|j5na_|U`mr)*$@`sSRl0N?X EKQuhIt^fc4 literal 0 HcmV?d00001 From c7ddfbe4ec3274292c813e82ac23c94c5ce06dfa Mon Sep 17 00:00:00 2001 From: TzeLoong Date: Sun, 19 Mar 2023 22:36:36 +0800 Subject: [PATCH 30/31] Improvements for v2-updated --- nova_data/nova_inputs.txt | 2 + src/main/java/duke/Deadline.java | 26 --- src/main/java/duke/Event.java | 32 ---- src/main/java/duke/Parser.java | 16 -- src/main/java/duke/Storage.java | 26 --- src/main/java/duke/Tasklist.java | 145 --------------- src/main/java/duke/Tasks.java | 50 ----- src/main/java/duke/ToDo.java | 21 --- src/main/java/duke/Ui.java | 26 --- src/main/java/{duke => nova}/Deadline.class | Bin src/main/java/nova/Deadline.java | 26 +++ src/main/java/{duke => nova}/Duke.class | Bin src/main/java/{duke => nova}/Event.class | Bin src/main/java/nova/Event.java | 28 +++ .../java/{duke/Duke.java => nova/Nova.java} | 40 ++-- src/main/java/nova/Parser.java | 16 ++ src/main/java/nova/Storage.java | 33 ++++ src/main/java/nova/Tasklist.java | 174 ++++++++++++++++++ src/main/java/{duke => nova}/Tasks.class | Bin src/main/java/nova/Tasks.java | 49 +++++ src/main/java/{duke => nova}/ToDo.class | Bin src/main/java/nova/ToDo.java | 21 +++ src/main/java/{duke => nova}/Ui.class | Bin src/main/java/nova/Ui.java | 27 +++ .../nova/exception/EmptyInputsException.java | 8 + .../java/nova/exception/ExceptionChecker.java | 12 ++ 26 files changed, 424 insertions(+), 354 deletions(-) create mode 100644 nova_data/nova_inputs.txt delete mode 100644 src/main/java/duke/Deadline.java delete mode 100644 src/main/java/duke/Event.java delete mode 100644 src/main/java/duke/Parser.java delete mode 100644 src/main/java/duke/Storage.java delete mode 100644 src/main/java/duke/Tasklist.java delete mode 100644 src/main/java/duke/Tasks.java delete mode 100644 src/main/java/duke/ToDo.java delete mode 100644 src/main/java/duke/Ui.java rename src/main/java/{duke => nova}/Deadline.class (100%) create mode 100644 src/main/java/nova/Deadline.java rename src/main/java/{duke => nova}/Duke.class (100%) rename src/main/java/{duke => nova}/Event.class (100%) create mode 100644 src/main/java/nova/Event.java rename src/main/java/{duke/Duke.java => nova/Nova.java} (57%) create mode 100644 src/main/java/nova/Parser.java create mode 100644 src/main/java/nova/Storage.java create mode 100644 src/main/java/nova/Tasklist.java rename src/main/java/{duke => nova}/Tasks.class (100%) create mode 100644 src/main/java/nova/Tasks.java rename src/main/java/{duke => nova}/ToDo.class (100%) create mode 100644 src/main/java/nova/ToDo.java rename src/main/java/{duke => nova}/Ui.class (100%) create mode 100644 src/main/java/nova/Ui.java create mode 100644 src/main/java/nova/exception/EmptyInputsException.java create mode 100644 src/main/java/nova/exception/ExceptionChecker.java diff --git a/nova_data/nova_inputs.txt b/nova_data/nova_inputs.txt new file mode 100644 index 000000000..210809b71 --- /dev/null +++ b/nova_data/nova_inputs.txt @@ -0,0 +1,2 @@ +[T][ ] fly +[D][ ] return book (by: Sunday) diff --git a/src/main/java/duke/Deadline.java b/src/main/java/duke/Deadline.java deleted file mode 100644 index 3ffa44abc..000000000 --- a/src/main/java/duke/Deadline.java +++ /dev/null @@ -1,26 +0,0 @@ -package duke; - -public class Deadline extends Tasks { - - protected String by; - - /** - * Creates a new Deadline object - * - * @param description the description of the task - * @param by the deadline of the task - */ - public Deadline(String description, String by) { - super(description); - this.by = by; - } - - /** - * Returns the string corresponding to the task icon and its deadline - */ - @Override - public String toString() { - return "[D]" + super.toString() + "(by:" + by + ")"; - } - -} diff --git a/src/main/java/duke/Event.java b/src/main/java/duke/Event.java deleted file mode 100644 index acc8223d8..000000000 --- a/src/main/java/duke/Event.java +++ /dev/null @@ -1,32 +0,0 @@ -package duke; - -public class Event extends Tasks { - protected String start; - protected String end; - - /** - * Creates a new Event object - * - * @param description the description of the task - * @param start the start time of the event - * @param end the end time of the event - */ - public Event(String description, String start, String end) { - super(description); - this.start = start; - this.end = end; - } - - /** - * Returns the string representation of the Event object - */ - - /** - * Returns the string corresponding to the task icon and the start, end time of - * the event - */ - @Override - public String toString() { - return "[E]" + super.toString() + "(" + start + end + ")"; - } -} diff --git a/src/main/java/duke/Parser.java b/src/main/java/duke/Parser.java deleted file mode 100644 index 050710abe..000000000 --- a/src/main/java/duke/Parser.java +++ /dev/null @@ -1,16 +0,0 @@ -package duke; - -import java.util.Scanner; - -public class Parser { - private static Scanner scan = new Scanner(System.in); - private static String input; - private static String[] command; - - public static String[] getCommand() { - input = scan.nextLine(); - command = input.split(" ", 2); - return command; - } - -} diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java deleted file mode 100644 index 0c3c1da39..000000000 --- a/src/main/java/duke/Storage.java +++ /dev/null @@ -1,26 +0,0 @@ -package duke; - -import java.io.File; -import java.io.FileNotFoundException; - -import java.util.NoSuchElementException; -import java.util.Scanner; - -public class Storage { - - private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; - - public static void findFile() { - try { - File file = new File(STORAGE_FILE_NAME); - Scanner scan = new Scanner(file); - while (scan.hasNext()) { - System.out.println(scan.nextLine()); - } - scan.close(); - } catch (FileNotFoundException | NoSuchElementException e) { - System.out.println("Error: File not found. Please try again"); - } - } - -} diff --git a/src/main/java/duke/Tasklist.java b/src/main/java/duke/Tasklist.java deleted file mode 100644 index c1d02e718..000000000 --- a/src/main/java/duke/Tasklist.java +++ /dev/null @@ -1,145 +0,0 @@ -package duke; - -import java.io.IOException; -import java.io.FileWriter; - -import java.util.ArrayList; - -public class Tasklist { - private static final String STORAGE_FILE_NAME = "./data/Duke.txt"; - - private static ArrayList listOfTasks = new ArrayList(); - private static int counter = 0; - - public static void print_action() { - System.out.println("\n"); - System.out.println("I have added this task: "); - System.out.println(listOfTasks.get(counter - 1).toString()); - - System.out.println("You now have " + counter + " tasks in the list."); - } - - public static void todo(String description) { - try { - Tasks t = new ToDo(description); - listOfTasks.add(t); - counter++; - print_action(); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } - } - - public static void deadline(String description, String by) { - try { - Deadline d = new Deadline(description, by); - listOfTasks.add(d); - counter++; - Tasklist.print_action(); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } - } - - public static void event(String description, String start, String end) { - try { - Event e = new Event(description, start, end); - listOfTasks.add(e); - counter++; - Tasklist.print_action(); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } - - } - - /** - * Prints out the tasks in the list - */ - public static void list() { - if (listOfTasks.isEmpty()) { - System.out.println("There are no tasks listed currently"); - } else { - System.out.println("Here are all of your " + counter + " tasks: "); - for (int i = 0; i < counter; i++) { - System.out.println(i + 1 + "." + listOfTasks.get(i).toString()); - } - } - } - - /** - * Deletes a task according to its index in the list - * - * @param index The index of the task. - * @throws IndexOutOfBoundsException If index provided is not within the list - */ - public static void delete(int index) { - try { - Tasks currentTask = listOfTasks.get(index - 1); - System.out.println("\n"); - System.out.println("Noted. I have deleted this task"); - System.out.println(currentTask.toString()); - listOfTasks.remove(index - 1); - counter--; - System.out.println("You now have " + counter + " tasks in the list."); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } - } - - /** - * Find tasks that matches a specific keyword in you - * - * @param keyword The keyword of the t - * - */ - public static void find(String keyword) { - if (listOfTasks.isEmpty()) { - System.out.println("There are no tasks listed currently"); - } else { - int index = 1; - for (int i = 0; i < listOfTasks.size(); i++) { - if (listOfTasks.get(i).description.contains(keyword)) { - if (index == 1) { - System.out.println("Here are the matching tasks in your list: "); - } - System.out.println(index + "." + listOfTasks.get(i).toString()); - index++; - } - } - } - } - - public static void markTask(int index) { - try { - listOfTasks.get(index - 1).markAsDone(); - System.out.println("Nice! This task is completed"); - System.out.println(listOfTasks.get(index - 1).toString()); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } - } - - public static void unmarkTask(int index) { - try { - listOfTasks.get(index - 1).markAsUnDone(); - System.out.println("Alright, this task has yet to be complete"); - System.out.println(listOfTasks.get(index - 1).toString()); - } catch (IndexOutOfBoundsException e) { - System.out.println(":( There is an error (Index is out of bounds/negative)"); - } - } - - public static void saveFile() { - try { - FileWriter writer = new FileWriter(STORAGE_FILE_NAME); - for (int i = 0; i < listOfTasks.size(); i++) { - writer.write(listOfTasks.get(i).toString() + '\n'); - } - writer.close(); - } catch (IOException e) { - System.out.println("Error: Tasks were not saved. Please try again"); - } - } - -} \ No newline at end of file diff --git a/src/main/java/duke/Tasks.java b/src/main/java/duke/Tasks.java deleted file mode 100644 index ed98ee04e..000000000 --- a/src/main/java/duke/Tasks.java +++ /dev/null @@ -1,50 +0,0 @@ -package duke; - -public class Tasks { - - protected String description; - protected boolean isDone; - - /** - * Constructor for a new Tasks object. Stores a description and status of the - * task. Status of the task is initialised as not done - * - * @param description the description of the new task - */ - public Tasks(String description) { - this.description = description; - this.isDone = false; - } - - /** - * A string represents the task icon - * - * @return the string representing the task icon - */ - public String getStatusIcon() { - return (isDone ? "[X]" : "[ ]"); // mark done task with X - } - - /** - * Set the task status as done - */ - public void markAsDone() { - this.isDone = true; - } - - /** - * Set the task status as not done - */ - public void markAsUnDone() { - this.isDone = false; - } - - /** - * Returns the string corresponding to the task icon and its description - */ - @Override - public String toString() { - return getStatusIcon() + " " + description; - } - -} diff --git a/src/main/java/duke/ToDo.java b/src/main/java/duke/ToDo.java deleted file mode 100644 index cf8f0d2b4..000000000 --- a/src/main/java/duke/ToDo.java +++ /dev/null @@ -1,21 +0,0 @@ -package duke; - -public class ToDo extends Tasks { - - /** - * Creates a new Todo object - * - * @param description the description of the task - */ - public ToDo(String description) { - super(description); - } - - /** - * Returns the string corresponding to the task icon and its description - */ - @Override - public String toString() { - return "[T]" + super.toString(); - } -} diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java deleted file mode 100644 index 08f7ca348..000000000 --- a/src/main/java/duke/Ui.java +++ /dev/null @@ -1,26 +0,0 @@ -package duke; - -public class Ui { - - /** - * Prints a welcome message - */ - public void greet_user() { - System.out.println("Hello! I'm Duke \n"); - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println(logo); - System.out.println("How can i help u? \n"); - } - - /** - * Prints an exit message - */ - public void goodbye_user() { - System.out.println("Goodbye. Hope to see u again :) \n"); - } - -} diff --git a/src/main/java/duke/Deadline.class b/src/main/java/nova/Deadline.class similarity index 100% rename from src/main/java/duke/Deadline.class rename to src/main/java/nova/Deadline.class diff --git a/src/main/java/nova/Deadline.java b/src/main/java/nova/Deadline.java new file mode 100644 index 000000000..fb12d644c --- /dev/null +++ b/src/main/java/nova/Deadline.java @@ -0,0 +1,26 @@ +package nova; + +public class Deadline extends Tasks { + + protected String by; + + /** + * Creates a new Deadline object + * + * @param description the description of the task + * @param by the deadline of the task + */ + public Deadline(String description, String by) { + super(description); + this.by = by; + } + + /** + * Returns the string corresponding to the task icon and its deadline + */ + @Override + public String toString() { + return "[D]" + super.toString() + "(by:" + by + ")"; + } + +} diff --git a/src/main/java/duke/Duke.class b/src/main/java/nova/Duke.class similarity index 100% rename from src/main/java/duke/Duke.class rename to src/main/java/nova/Duke.class diff --git a/src/main/java/duke/Event.class b/src/main/java/nova/Event.class similarity index 100% rename from src/main/java/duke/Event.class rename to src/main/java/nova/Event.class diff --git a/src/main/java/nova/Event.java b/src/main/java/nova/Event.java new file mode 100644 index 000000000..09a06b582 --- /dev/null +++ b/src/main/java/nova/Event.java @@ -0,0 +1,28 @@ +package nova; + +public class Event extends Tasks { + protected String start; + protected String end; + + /** + * Creates a new Event object + * + * @param description the description of the task + * @param start the start time of the event + * @param end the end time of the event + */ + public Event(String description, String start, String end) { + super(description); + this.start = start; + this.end = end; + } + + /** + * Returns the string corresponding to the task icon and the start, end time of + * the event + */ + @Override + public String toString() { + return "[E]" + super.toString() + "(" + "from: " + start + "to: " + end + ")"; + } +} diff --git a/src/main/java/duke/Duke.java b/src/main/java/nova/Nova.java similarity index 57% rename from src/main/java/duke/Duke.java rename to src/main/java/nova/Nova.java index f9a77412d..405cc8ab3 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/nova/Nova.java @@ -1,16 +1,24 @@ -package duke; +package nova; -public class Duke { +import java.io.FileNotFoundException; +import nova.exception.EmptyInputsException; +import nova.exception.ExceptionChecker; - public static void main(String[] args) { - Ui ui = new Ui(); - ui.greet_user(); - Storage.findFile(); +public class Nova { + + public static void main(String[] args) throws EmptyInputsException { + try { + Ui.greet_user(); + Storage.checkFile(); + } catch (FileNotFoundException e) { + System.out.println("File does not exist."); + } String[] command = Parser.getCommand(); while (!"bye".equals(command[0])) { - switch (command[0]) { + try { + switch (command[0]) { case "todo": Tasklist.todo(command[1]); break; @@ -18,13 +26,18 @@ public static void main(String[] args) { String[] d = command[1].split("/by", 2); String d_description = d[0]; String d_by = d[1]; + ExceptionChecker.checkEmptyString(d_description); + ExceptionChecker.checkEmptyString(d_by); Tasklist.deadline(d_description, d_by); break; case "event": - String[] er = command[1].split("/", 3); + String[] er = command[1].split("/from|/to", 3); String e_description = er[0]; String e_start = er[1]; String e_end = er[2]; + ExceptionChecker.checkEmptyString(e_description); + ExceptionChecker.checkEmptyString(e_start); + ExceptionChecker.checkEmptyString(e_end); Tasklist.event(e_description, e_start, e_end); break; case "list": @@ -47,14 +60,17 @@ public static void main(String[] args) { Tasklist.find(keyword); break; default: - System.out.println("There was an error. Please try again"); + System.out.println("Command not recognised. Please try again"); break; + } + } catch (ArrayIndexOutOfBoundsException e) { + System.out.println("Command is incomplete. Please try again!"); + } catch (EmptyInputsException a) { + System.out.println(a.getMessage()); } command = Parser.getCommand(); } - - ui.goodbye_user(); + Ui.goodbye_user(); Tasklist.saveFile(); } - } \ No newline at end of file diff --git a/src/main/java/nova/Parser.java b/src/main/java/nova/Parser.java new file mode 100644 index 000000000..7f445fca4 --- /dev/null +++ b/src/main/java/nova/Parser.java @@ -0,0 +1,16 @@ +package nova; + +import java.util.Scanner; + +public class Parser { + private static Scanner scan = new Scanner(System.in); + private static String input; + private static String[] command; + + public static String[] getCommand() { + input = scan.nextLine(); + command = input.split(" ", 2); + return command; + } + +} diff --git a/src/main/java/nova/Storage.java b/src/main/java/nova/Storage.java new file mode 100644 index 000000000..a06f3b3ce --- /dev/null +++ b/src/main/java/nova/Storage.java @@ -0,0 +1,33 @@ +package nova; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +public class Storage { + + private static final String directoryPath = "nova_data"; + private static final String filePath = "nova_data/nova_inputs.txt"; + + /** + * Creates a new data file and folder if necessary. + */ + public static void findFile() throws IOException { + File directory = new File(directoryPath); + if (!directory.exists()) { + directory.mkdir(); + } + File saveFile = new File(filePath); + if (!saveFile.exists()) { + saveFile.createNewFile(); + } + } + + public static void checkFile() throws FileNotFoundException { + try { + findFile(); + } catch (IOException e) { + System.out.println("Error saving file!"); + } + } +} diff --git a/src/main/java/nova/Tasklist.java b/src/main/java/nova/Tasklist.java new file mode 100644 index 000000000..2b72a578d --- /dev/null +++ b/src/main/java/nova/Tasklist.java @@ -0,0 +1,174 @@ +package nova; + +import java.io.IOException; +import java.io.FileWriter; + +import java.util.ArrayList; + +public class Tasklist { + private static final String filePath = "nova_data/nova_inputs.txt"; + + private static ArrayList listOfTasks = new ArrayList(); + private static int counter = 0; + + public static void print_action() { + System.out.println("\nI have added this task: "); + System.out.println(listOfTasks.get(counter - 1).toString()); + + System.out.println("You now have " + counter + " tasks in the list."); + } + + /** + * Adds a new task of type todo into the list of tasks. + * + * @param description The description of the task. + * @throws IndexOutOfBoundsException If some input parameters are missing + */ + public static void todo(String description) { + try { + Tasks t = new ToDo(description); + listOfTasks.add(t); + counter++; + print_action(); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + /** + * Adds a new task of type deadline into the list of tasks. + * + * @param description The description of the task. + * @param by The deadline of the task. + * @throws IndexOutOfBoundsException If some input parameters are missing + */ + public static void deadline(String description, String by) { + try { + Deadline d = new Deadline(description, by); + listOfTasks.add(d); + counter++; + Tasklist.print_action(); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + /** + * Adds a new task of type event into the list of tasks. + * + * @param description The description of the task. + * @param start The starting time of the task. + * @param end The ending time of the task. + * @throws IndexOutOfBoundsException If some parameters are missing + */ + public static void event(String description, String start, String end) { + try { + Event e = new Event(description, start, end); + listOfTasks.add(e); + counter++; + Tasklist.print_action(); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + + } + + /** + * Prints out the tasks in the list + */ + public static void list() { + if (listOfTasks.isEmpty()) { + System.out.println("There are no tasks listed currently"); + } else { + System.out.println("Here are all of your " + counter + " tasks: "); + for (int i = 0; i < counter; i++) { + System.out.println(i + 1 + "." + listOfTasks.get(i).toString()); + } + } + } + + /** + * Deletes a task according to its index in the list + * + * @param index The index of the task. + * @throws IndexOutOfBoundsException If index provided is not within the list + */ + public static void delete(int index) { + try { + Tasks currentTask = listOfTasks.get(index - 1); + System.out.println("\n"); + System.out.println("Noted. I have deleted this task"); + System.out.println(currentTask.toString()); + listOfTasks.remove(index - 1); + counter--; + System.out.println("You now have " + counter + " tasks in the list."); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + /** + * Find tasks that matches a specific keyword in you + * + * @param keyword The keyword of the t + * + */ + public static void find(String keyword) { + if (listOfTasks.isEmpty()) { + System.out.println("There are no tasks listed currently"); + } else { + int index = 1; + for (int i = 0; i < listOfTasks.size(); i++) { + if (listOfTasks.get(i).description.contains(keyword)) { + if (index == 1) { + System.out.println("Here are the matching tasks in your list: "); + } + System.out.println(index + "." + listOfTasks.get(i).toString()); + index++; + } + } + } + } + + /** + * Marks a task as done based on the its index in the printed list of tasks. + * + * @param index The index of the task. + */ + public static void markTask(int index) { + try { + listOfTasks.get(index - 1).markAsDone(); + System.out.println("Nice! This task is completed"); + System.out.println(listOfTasks.get(index - 1).toString()); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + /** + * Marks a task as undone based on the its index in the printed list of tasks. + * + * @param index The index of the task. + */ + public static void unmarkTask(int index) { + try { + listOfTasks.get(index - 1).markAsUnDone(); + System.out.println("Alright, this task has yet to be complete"); + System.out.println(listOfTasks.get(index - 1).toString()); + } catch (IndexOutOfBoundsException e) { + System.out.println(":( There is an error (Index is out of bounds/negative)"); + } + } + + public static void saveFile() { + try { + FileWriter writer = new FileWriter(filePath); + for (int i = 0; i < listOfTasks.size(); i++) { + writer.write(listOfTasks.get(i).toString() + '\n'); + } + writer.close(); + } catch (IOException e) { + System.out.println("Error: Tasks were not saved. Please try again"); + } + } +} \ No newline at end of file diff --git a/src/main/java/duke/Tasks.class b/src/main/java/nova/Tasks.class similarity index 100% rename from src/main/java/duke/Tasks.class rename to src/main/java/nova/Tasks.class diff --git a/src/main/java/nova/Tasks.java b/src/main/java/nova/Tasks.java new file mode 100644 index 000000000..9b17eda04 --- /dev/null +++ b/src/main/java/nova/Tasks.java @@ -0,0 +1,49 @@ +package nova; + +public class Tasks { + + protected String description; + protected boolean isDone; + + /** + * Constructor for a new Tasks object. Stores a description and status of the + * task. Status of the task is initialised as not done + * + * @param description the description of the new task + */ + public Tasks(String description) { + this.description = description; + this.isDone = false; + } + + /** + * A string represents the task icon + * + * @return the string representing the task icon + */ + public String getStatusIcon() { + return (isDone ? "[X]" : "[ ]"); // mark done task with X + } + + /** + * Set the task status as done + */ + public void markAsDone() { + this.isDone = true; + } + + /** + * Set the task status as not done + */ + public void markAsUnDone() { + this.isDone = false; + } + + /** + * Returns the string corresponding to the task icon and its description + */ + @Override + public String toString() { + return getStatusIcon() + " " + description; + } +} diff --git a/src/main/java/duke/ToDo.class b/src/main/java/nova/ToDo.class similarity index 100% rename from src/main/java/duke/ToDo.class rename to src/main/java/nova/ToDo.class diff --git a/src/main/java/nova/ToDo.java b/src/main/java/nova/ToDo.java new file mode 100644 index 000000000..d483b1244 --- /dev/null +++ b/src/main/java/nova/ToDo.java @@ -0,0 +1,21 @@ +package nova; + +public class ToDo extends Tasks { + + /** + * Creates a new Todo object + * + * @param description the description of the task + */ + public ToDo(String description) { + super(description); + } + + /** + * Returns the string corresponding to the task icon and its description + */ + @Override + public String toString() { + return "[T]" + super.toString(); + } +} diff --git a/src/main/java/duke/Ui.class b/src/main/java/nova/Ui.class similarity index 100% rename from src/main/java/duke/Ui.class rename to src/main/java/nova/Ui.class diff --git a/src/main/java/nova/Ui.java b/src/main/java/nova/Ui.java new file mode 100644 index 000000000..a71ffc9d3 --- /dev/null +++ b/src/main/java/nova/Ui.java @@ -0,0 +1,27 @@ +package nova; + +public class Ui { + public static final String LOGO = " __ _ __ _ _ __\n" + + "( ( \\ / \\ / )( \\ / _\\ \n" + + "/ /( O )\\ \\/ // \\ \n" + + "\\_)__) \\__/ \\__/ \\_/\\_/ \n"; + + public static final String WELCOME_MESSAGE = "Hello! I'm your assistant \n"; + public static final String GREETING_MESAGE = "\nHow can i help u? \n"; + public static final String FAREWELL_MESSAGE = "Goodbye. Hope to see u again :) \n"; + + /** + * Prints a welcome message + */ + public static void greet_user() { + System.out.println(WELCOME_MESSAGE + LOGO + GREETING_MESAGE); + } + + /** + * Prints an exit message + */ + public static void goodbye_user() { + System.out.println(FAREWELL_MESSAGE); + } + +} diff --git a/src/main/java/nova/exception/EmptyInputsException.java b/src/main/java/nova/exception/EmptyInputsException.java new file mode 100644 index 000000000..fab3e55d9 --- /dev/null +++ b/src/main/java/nova/exception/EmptyInputsException.java @@ -0,0 +1,8 @@ +package nova.exception; + +public class EmptyInputsException extends Exception { + @Override + public String getMessage() { + return "One of your inputs is empty. Please try again"; + } +} \ No newline at end of file diff --git a/src/main/java/nova/exception/ExceptionChecker.java b/src/main/java/nova/exception/ExceptionChecker.java new file mode 100644 index 000000000..f76bd5b2f --- /dev/null +++ b/src/main/java/nova/exception/ExceptionChecker.java @@ -0,0 +1,12 @@ +package nova.exception; + +/** + * An exception for the issue when one of the task inputs is missing + */ +public class ExceptionChecker { + public static void checkEmptyString(String string) throws EmptyInputsException { + if (string.isEmpty()) { + throw new EmptyInputsException(); + } + } +} From 1ad8a59a932c7ede8f9b2d6ec39b545d99ced9de Mon Sep 17 00:00:00 2001 From: TzeLoong <75962194+TzeLoong@users.noreply.github.com> Date: Sun, 19 Mar 2023 22:39:53 +0800 Subject: [PATCH 31/31] Improvements for v0.2-updated --- docs/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/README.md b/docs/README.md index 80458377e..058a1f807 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # User Guide -Duke is a command-line (CLI) chatbot application that helps you keep track of your tasks. +Nova is a command-line (CLI) chatbot application that helps you keep track of your tasks. ## Features @@ -43,7 +43,7 @@ Example of usage: Expected outcome: -Duke will acknowledge and display the updated list +Nova will acknowledge and display the updated list ``` Here are all of your 3 tasks: @@ -63,7 +63,7 @@ Example of usage: Expected outcome: -Duke will acknowledge the added task and display the updated number of tasks +Nova will acknowledge the added task and display the updated number of tasks ``` I have added this task: @@ -82,7 +82,7 @@ e.g. {deadline eat /by 14 July 2023 6pm} Expected outcome: -Duke will acknowledge the added task and display the updated number of tasks +Nova will acknowledge the added task and display the updated number of tasks ``` I have added this task: @@ -101,7 +101,7 @@ e.g. {event sleep /from 1 June /to 2 June} Expected outcome: -Duke will acknowledge the added task and display the updated number of tasks +Nova will acknowledge the added task and display the updated number of tasks ``` I have added this task: @@ -119,7 +119,7 @@ Example of usage: Expected outcome: -Duke will acknowledge and display the marked task +Nova will acknowledge and display the marked task ``` Nice! This task is completed @@ -136,7 +136,7 @@ Example of usage: Expected outcome: -Duke will acknowledge and display the unmarked task +Nova will acknowledge and display the unmarked task ``` Alright, this task has yet to be complete @@ -153,7 +153,7 @@ Example of usage: Expected outcome: -Duke will acknowledge, delete the unmarked task and display the updated number of tasks +Nova will acknowledge, delete the unmarked task and display the updated number of tasks ``` Noted. I have deleted this task @@ -172,7 +172,7 @@ Example of usage: Expected outcome: -Duke will acknowledge, search for the related tasks and display accordingly +Nova will acknowledge, search for the related tasks and display accordingly ``` Here are the matching tasks in your list: @@ -190,7 +190,7 @@ Example of usage: Expected outcome: -Duke will greet you farewell +Nova will greet you farewell ``` Goodbye. Hope to see u again :)