From f76b5f2f945643ee61f95deefb09a0e43c11f0c0 Mon Sep 17 00:00:00 2001 From: VishalJeyaram <69350459+VishalJeyaram@users.noreply.github.com> Date: Fri, 1 Oct 2021 14:18:59 +0800 Subject: [PATCH 001/398] Set theme jekyll-theme-modernist --- docs/_config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/_config.yml diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000000..cc35c1df2c --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-modernist \ No newline at end of file From f638e131c82c859de5c5ad9cb7a3d4767ac1a4ca Mon Sep 17 00:00:00 2001 From: teoziyiivy Date: Mon, 4 Oct 2021 21:01:12 +0800 Subject: [PATCH 002/398] Edit About Us --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 0f072953ea..a0cebf7258 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -5,5 +5,5 @@ Display | Name | Github Profile | Portfolio ![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) ![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) From 54a96cdaee951e4b464dae13cde6c592aae96761 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Mon, 4 Oct 2021 21:26:02 +0800 Subject: [PATCH 003/398] add name plus particulars --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 0f072953ea..34a2792a36 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -2,7 +2,7 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: -![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) ![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) From 18a77ab99408ba5fde34d3291994ca8ee2f5a421 Mon Sep 17 00:00:00 2001 From: VishalJeyaram Date: Mon, 4 Oct 2021 21:26:30 +0800 Subject: [PATCH 004/398] About us name and link added --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 0f072953ea..dc9f3d18a8 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -6,4 +6,4 @@ Display | Name | Github Profile | Portfolio ![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Vishal Jeyaram | [Github](https://github.com/VishalJeyaram) | [Portfolio](https://www.linkedin.com/in/vishal-j-a43b581a2) From 24516a636992eaadad9b85e44745419bccd20fc9 Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Mon, 4 Oct 2021 21:34:28 +0800 Subject: [PATCH 005/398] Add AboutUs --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 0f072953ea..00a24122d7 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -3,7 +3,7 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: ![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) ![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) From 0603c12c4bd13d9fc6ca8b807af5182cb2d0cfbb Mon Sep 17 00:00:00 2001 From: arvejw Date: Mon, 4 Oct 2021 21:37:01 +0800 Subject: [PATCH 006/398] Add name and github profile to AboutUs.md --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 0f072953ea..2cb6700b73 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -4,6 +4,6 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: ![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) From 079925a3b0a60bd648ad7c647eb6db98697cbbcd Mon Sep 17 00:00:00 2001 From: arvejw Date: Mon, 4 Oct 2021 21:45:07 +0800 Subject: [PATCH 007/398] Add portfolio to AboutUs.md --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 2cb6700b73..72128e3a7f 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -4,6 +4,6 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: ![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) ![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) From 37752987c706ed923bbe6e21b03e08520aaab3ef Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Mon, 4 Oct 2021 21:47:12 +0800 Subject: [PATCH 008/398] Add avatar-AboutUs --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 00a24122d7..41cdff54dc 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -3,7 +3,7 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: ![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) +![https://avatars.githubusercontent.com/u/69446495?v=4](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) ![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) ![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) From de08215fdb301c0ffab0913c6524b58af656da58 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Mon, 4 Oct 2021 22:06:00 +0800 Subject: [PATCH 009/398] add picture --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 6d7df43d5b..1b1d65c200 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -2,7 +2,7 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: -![](https://via.placeholder.com/100.png?text=Photo) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) +![Imgur](https://i.imgur.com/3ubqQJI.jpg) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) ![https://avatars.githubusercontent.com/u/69446495?v=4](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) ![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) ![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) From 93cb4d80f8b8475e61e5940b1a9d8e591fbe9f5f Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Mon, 4 Oct 2021 22:12:32 +0800 Subject: [PATCH 010/398] Add avatar-AboutUs --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 1b1d65c200..67a39f215c 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -3,7 +3,7 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: ![Imgur](https://i.imgur.com/3ubqQJI.jpg) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) -![https://avatars.githubusercontent.com/u/69446495?v=4](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) +![](https://user-images.githubusercontent.com/69446495/135865625-37a574c0-5092-4685-aaf6-b20e24d9c9a4.jpg) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) ![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) ![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) ![](https://via.placeholder.com/100.png?text=Photo) | Vishal Jeyaram | [Github](https://github.com/VishalJeyaram) | [Portfolio](https://www.linkedin.com/in/vishal-j-a43b581a2) From aa31c965994a25d87331de07afc7159676ac73bf Mon Sep 17 00:00:00 2001 From: teoziyiivy <69446729+teoziyiivy@users.noreply.github.com> Date: Mon, 4 Oct 2021 22:12:54 +0800 Subject: [PATCH 011/398] Revert "Pull request to fork" --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 1b1d65c200..6d7df43d5b 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -2,7 +2,7 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: -![Imgur](https://i.imgur.com/3ubqQJI.jpg) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) +![](https://via.placeholder.com/100.png?text=Photo) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) ![https://avatars.githubusercontent.com/u/69446495?v=4](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) ![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) ![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) From 725266124a0a2339aedf156bdde2b65e1a0793d3 Mon Sep 17 00:00:00 2001 From: teoziyiivy <69446729+teoziyiivy@users.noreply.github.com> Date: Mon, 4 Oct 2021 22:13:40 +0800 Subject: [PATCH 012/398] Revert "Pull request to update fork." --- docs/AboutUs.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 6d7df43d5b..0f072953ea 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -2,8 +2,8 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: -![](https://via.placeholder.com/100.png?text=Photo) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) -![https://avatars.githubusercontent.com/u/69446495?v=4](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) -![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) -![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) -![](https://via.placeholder.com/100.png?text=Photo) | Vishal Jeyaram | [Github](https://github.com/VishalJeyaram) | [Portfolio](https://www.linkedin.com/in/vishal-j-a43b581a2) +![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) From e9d34fb56d54ad34f54bff2ad4febd9b8d39b6ce Mon Sep 17 00:00:00 2001 From: teoziyiivy Date: Mon, 4 Oct 2021 22:25:39 +0800 Subject: [PATCH 013/398] Fix AboutUs --- docs/AboutUs.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 0f072953ea..1b1d65c200 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -2,8 +2,8 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: -![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +![Imgur](https://i.imgur.com/3ubqQJI.jpg) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) +![https://avatars.githubusercontent.com/u/69446495?v=4](https://via.placeholder.com/100.png?text=Photo) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) +![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) +![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) +![](https://via.placeholder.com/100.png?text=Photo) | Vishal Jeyaram | [Github](https://github.com/VishalJeyaram) | [Portfolio](https://www.linkedin.com/in/vishal-j-a43b581a2) From 27132a5da8c2ee01cf106e53de2193e5789ae661 Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Mon, 4 Oct 2021 23:46:20 +0800 Subject: [PATCH 014/398] Add avatar --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 67a39f215c..be940947cb 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -3,7 +3,7 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: ![Imgur](https://i.imgur.com/3ubqQJI.jpg) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) -![](https://user-images.githubusercontent.com/69446495/135865625-37a574c0-5092-4685-aaf6-b20e24d9c9a4.jpg) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) +![](https://user-images.githubusercontent.com/69446495/135881811-957f79eb-0afe-48dd-94f0-d237edce256a.jpg) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) ![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) ![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) ![](https://via.placeholder.com/100.png?text=Photo) | Vishal Jeyaram | [Github](https://github.com/VishalJeyaram) | [Portfolio](https://www.linkedin.com/in/vishal-j-a43b581a2) From 30705f417794e2aa04e31fbcbd804c35cb830dc6 Mon Sep 17 00:00:00 2001 From: teoziyiivy Date: Wed, 6 Oct 2021 14:06:09 +0800 Subject: [PATCH 015/398] Added weight tracker --- .../java/seedu/duke/AddWeightException.java | 4 ++ src/main/java/seedu/duke/Duke.java | 65 +++++++++++++++---- src/main/java/seedu/duke/WeightTracker.java | 23 +++++++ text-ui-test/EXPECTED.TXT | 16 ++--- text-ui-test/input.txt | 5 +- 5 files changed, 91 insertions(+), 22 deletions(-) create mode 100644 src/main/java/seedu/duke/AddWeightException.java create mode 100644 src/main/java/seedu/duke/WeightTracker.java diff --git a/src/main/java/seedu/duke/AddWeightException.java b/src/main/java/seedu/duke/AddWeightException.java new file mode 100644 index 0000000000..f4264bd8ad --- /dev/null +++ b/src/main/java/seedu/duke/AddWeightException.java @@ -0,0 +1,4 @@ +package seedu.duke; + +public class AddWeightException extends Exception { +} diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 5c74e68d59..4292cd075b 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,21 +1,62 @@ package seedu.duke; +import java.util.ArrayList; import java.util.Scanner; public class Duke { - /** - * Main entry-point for the java.duke.Duke application. - */ - public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); - System.out.println("What is your name?"); + public static ArrayList weights = new ArrayList<>(); + + public static void printAddWeightResponse() { + System.out.println("Noted! CLI.ckFit has recorded your weight as " + weights.get(weights.size() - 1).getWeight() + ". Check back for your progress!"); + } + + public static void printAddWeightException() { + System.out.println("There was a problem adding your weight."); + } + + public static void addWeight(String line) throws AddWeightException { + if (!line.matches("(.*) (.*)")) { + throw new AddWeightException(); + } else { + //extracting the weight and date + String weight = line.replaceAll(" .+", ""); + String date = line.replaceAll(".+ ", ""); + weights.add(new WeightTracker(weight, date)); + printAddWeightResponse(); + } + } + public static void printWeight() { + System.out.println("Here are your recorded weights:"); + for (int i = 0; i < weights.size(); i++) { + weights.get(i).checkWeight(); + } + + } + + public static void readInput(String line) { + String[] splitLine = line.split(" ", 2); + String command = splitLine[0]; + line = line.replaceAll("^" + command + " ", ""); + if (command.equals("checkweight")) { + printWeight(); + } else if (command.equals("saveweight")) { + try { + addWeight(line); + } catch (AddWeightException e) { + printAddWeightException(); + } + } + } + + public static void main(String[] args) { + String line; Scanner in = new Scanner(System.in); - System.out.println("Hello " + in.nextLine()); + line = in.nextLine(); + //continue to run program unless types "bye" to exit program + while (!line.equals("bye")) { + readInput(line); + line = in.nextLine(); + } } } diff --git a/src/main/java/seedu/duke/WeightTracker.java b/src/main/java/seedu/duke/WeightTracker.java new file mode 100644 index 0000000000..dc1513561d --- /dev/null +++ b/src/main/java/seedu/duke/WeightTracker.java @@ -0,0 +1,23 @@ +package seedu.duke; + +public class WeightTracker { + private String weight; + private String date; + + public WeightTracker(String weight, String date) { + this.weight = weight; + this.date = date; + } + + public String getWeight() { + return weight; + } + + public String getDate() { + return date; + } + + public void checkWeight() { + System.out.println("Your weight was " + getWeight() + " on " + getDate() + "."); + } +} diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 892cb6cae7..0c70e674b6 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,9 +1,7 @@ -Hello from - ____ _ -| _ \ _ _| | _____ -| | | | | | | |/ / _ \ -| |_| | |_| | < __/ -|____/ \__,_|_|\_\___| - -What is your name? -Hello James Gosling +Noted! CLI.ckFit has recorded your weight as 50. Check back for your progress! +Here are your recorded weights: +Your weight was 50 on 9/6/2021. +Noted! CLI.ckFit has recorded your weight as 40. Check back for your progress! +Here are your recorded weights: +Your weight was 50 on 9/6/2021. +Your weight was 40 on 10/6/2021. \ No newline at end of file diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index f6ec2e9f95..983c0f6684 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -1 +1,4 @@ -James Gosling \ No newline at end of file +saveweight 50 9/6/2021 +checkweight +saveweight 40 10/6/2021 +checkweight \ No newline at end of file From 2f7e4c7a4f9b3efc0681c84c362c0a0a3d510f71 Mon Sep 17 00:00:00 2001 From: arvejw Date: Wed, 6 Oct 2021 21:20:20 +0800 Subject: [PATCH 016/398] Add basic gym related functionalities --- .../seedu/duke/gym/CompletedGymWorkout.java | 18 +++ src/main/java/seedu/duke/gym/GymManager.java | 109 ++++++++++++++++++ src/main/java/seedu/duke/gym/GymWorkout.java | 27 +++++ 3 files changed, 154 insertions(+) create mode 100644 src/main/java/seedu/duke/gym/CompletedGymWorkout.java create mode 100644 src/main/java/seedu/duke/gym/GymManager.java create mode 100644 src/main/java/seedu/duke/gym/GymWorkout.java diff --git a/src/main/java/seedu/duke/gym/CompletedGymWorkout.java b/src/main/java/seedu/duke/gym/CompletedGymWorkout.java new file mode 100644 index 0000000000..fb55c31fd4 --- /dev/null +++ b/src/main/java/seedu/duke/gym/CompletedGymWorkout.java @@ -0,0 +1,18 @@ +package seedu.duke.gym; + +public class CompletedGymWorkout extends GymWorkout { + private int caloriesBurned; + + public CompletedGymWorkout(String activityDescription, String activityAt, int caloriesBurned) { + super(activityDescription, activityAt); + this.caloriesBurned = caloriesBurned; + } + + public int getCaloriesBurned() { + return caloriesBurned; + } + + public void setCaloriesBurned(int caloriesBurned) { + this.caloriesBurned = caloriesBurned; + } +} diff --git a/src/main/java/seedu/duke/gym/GymManager.java b/src/main/java/seedu/duke/gym/GymManager.java new file mode 100644 index 0000000000..3b1c31a1dd --- /dev/null +++ b/src/main/java/seedu/duke/gym/GymManager.java @@ -0,0 +1,109 @@ +package seedu.duke.gym; + +import java.util.ArrayList; + +public class GymManager { + private ArrayList gymScheduleList; + private ArrayList completedGymWorkoutList; + private static final int LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING = 1; + private static final int OFFSET_BY_1 = 1; //OFFSET to convert between 0 & 1's Indexing + + public GymManager() { + gymScheduleList = new ArrayList(); + completedGymWorkoutList = new ArrayList(); + } + + public void addGymWorkout(String activityDescription, String activityAt) { + gymScheduleList.add(new GymWorkout(activityDescription, activityAt)); + } + + public void deleteGymWorkout(int workoutNumber) { + // short circuit if empty + if (gymScheduleList.isEmpty()) { + System.out.println("List is empty"); + return; + } + if (isWorkoutNumberWithinRange(workoutNumber)) { + gymScheduleList.remove(workoutNumber - OFFSET_BY_1); + } else { + System.out.println("Invalid Activity number"); + } + } + + public boolean isWorkoutNumberWithinRange(int workoutNumber) { + //short circuit if empty + if (gymScheduleList.isEmpty()) { + return false; + } + int upperBound = gymScheduleList.size(); + int lowerBound = LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING; // equals 1 + return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound) ? true : false; + } + + // if activity exists in schedule list can use activity number + // once date/time properly implemented only workouts on the current date can be "done" + public void doneGymWorkout(int workoutNumber, int caloriesBurned) { + //short circuit if empty + if (gymScheduleList.isEmpty()) { + System.out.println("List is empty"); + return; + } + if (isWorkoutNumberWithinRange(workoutNumber)) { + completedGymWorkoutList.add( + new CompletedGymWorkout(gymScheduleList.get(workoutNumber - OFFSET_BY_1).getWorkoutDescription(), + gymScheduleList.get(workoutNumber - OFFSET_BY_1).getWorkoutAt(), caloriesBurned) + ); + } else { + System.out.println("Invalid Activity number"); + } + } + + // completing activity that is not in gym schedule + public void doneGymWorkout(String workoutDescription, String workoutAt, int caloriesBurned) { + completedGymWorkoutList.add( + new CompletedGymWorkout(workoutDescription, workoutAt, caloriesBurned) + ); + } + + public void deleteCompletedGymWorkout(int activityWorkout) { + // short circuit if empty + if (completedGymWorkoutList.isEmpty()) { + System.out.println("List is empty"); + return; + } + if (isWorkoutNumberWithinRange(activityWorkout)) { + completedGymWorkoutList.remove(activityWorkout - OFFSET_BY_1); + } else { + System.out.println("Invalid Activity number"); + } + } + + public void printGymSchedule() { + // short circuit if empty + if (gymScheduleList.isEmpty()) { + System.out.println("List is empty"); + return; + } + int currentIndex = 1; + for (GymWorkout a : gymScheduleList) { + //placeholder before user interface class implemented + System.out.println(currentIndex + ". " + a.getWorkoutDescription() + "(at: " + a.getWorkoutAt() + ")"); + currentIndex++; + } + } + + public void printCompletedGymWorkouts() { + // short circuit if empty + if (completedGymWorkoutList.isEmpty()) { + System.out.println("Completed list is empty"); + return; + } + int currentIndex = 1; + for (CompletedGymWorkout a : completedGymWorkoutList) { + //placeholder before user interface class implemented + System.out.println(currentIndex + ". " + a.getWorkoutDescription() + "(at: " + a.getWorkoutAt() + + ")(calories burned: " + a.getCaloriesBurned() + ")"); + currentIndex++; + } + } +} diff --git a/src/main/java/seedu/duke/gym/GymWorkout.java b/src/main/java/seedu/duke/gym/GymWorkout.java new file mode 100644 index 0000000000..59f154b20e --- /dev/null +++ b/src/main/java/seedu/duke/gym/GymWorkout.java @@ -0,0 +1,27 @@ +package seedu.duke.gym; + +public class GymWorkout { + private String workoutDescription; + private String workoutAt; //todo: store as DateTime instead of String + + public GymWorkout(String workoutDescription, String workoutAt) { + this.workoutDescription = workoutDescription; + this.workoutAt = workoutAt; + } + + public String getWorkoutDescription() { + return workoutDescription; + } + + public void setWorkoutDescription(String workoutDescription) { + this.workoutDescription = workoutDescription; + } + + public String getWorkoutAt() { + return workoutAt; + } + + public void setWorkoutAt(String workoutAt) { + this.workoutAt = workoutAt; + } +} From fcf88d232c53a4e4ae14e460135365e034388f99 Mon Sep 17 00:00:00 2001 From: arvejw Date: Wed, 6 Oct 2021 21:35:19 +0800 Subject: [PATCH 017/398] Update AboutUs image --- docs/AboutUs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AboutUs.md b/docs/AboutUs.md index be940947cb..a94d70ae2b 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -4,6 +4,6 @@ Display | Name | Github Profile | Portfolio --------|:----:|:--------------:|:---------: ![Imgur](https://i.imgur.com/3ubqQJI.jpg) | Edward Wang | [Github](https://github.com/EdwardZYWang) | [Portfolio](https://www.linkedin.com/in/edward-w-220218206/) ![](https://user-images.githubusercontent.com/69446495/135881811-957f79eb-0afe-48dd-94f0-d237edce256a.jpg) | Samal Sthitipragyan | [Github](https://github.com/pragyan01) | [Portfolio](https://www.linkedin.com/in/pragyan01/) -![](https://via.placeholder.com/100.png?text=Photo) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) +![](https://avatars0.githubusercontent.com/arvejw?s=100) | Teh Jiewen | [Github](https://github.com/arvejw) | [Portfolio](www.linkedin.com/in/jiewen-teh) ![](https://avatars0.githubusercontent.com/teoziyiivy?s=100) | Teo Ziyi Ivy | [Github](https://github.com/teoziyiivy) | [Portfolio](https://www.linkedin.com/in/teoziyiivy/) ![](https://via.placeholder.com/100.png?text=Photo) | Vishal Jeyaram | [Github](https://github.com/VishalJeyaram) | [Portfolio](https://www.linkedin.com/in/vishal-j-a43b581a2) From a2b8850e127a50c1a3180147f93fea037d81df21 Mon Sep 17 00:00:00 2001 From: VishalJeyaram Date: Thu, 7 Oct 2021 01:13:09 +0800 Subject: [PATCH 018/398] Meal, DukeException and Ui classes added to allow user to add meals. --- src/main/java/seedu/duke/Duke.java | 36 ++++++++++++++----- src/main/java/seedu/duke/DukeException.java | 8 +++++ src/main/java/seedu/duke/Meal.java | 39 +++++++++++++++++++++ src/main/java/seedu/duke/Ui.java | 19 ++++++++++ 4 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 src/main/java/seedu/duke/DukeException.java create mode 100644 src/main/java/seedu/duke/Meal.java create mode 100644 src/main/java/seedu/duke/Ui.java diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 5c74e68d59..0b6e23f3eb 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,21 +1,41 @@ package seedu.duke; -import java.util.Scanner; +import java.time.format.DateTimeParseException; public class Duke { - /** - * Main entry-point for the java.duke.Duke application. - */ - public static void main(String[] args) { + + private Meal meal; + private Ui ui; + + public Duke() { + meal = new Meal(); + ui = new Ui(); String logo = " ____ _ \n" + "| _ \\ _ _| | _____ \n" + "| | | | | | | |/ / _ \\\n" + "| |_| | |_| | < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; System.out.println("Hello from\n" + logo); - System.out.println("What is your name?"); + System.out.println("Enter the name of a meal, its calories, and today's date!"); + } - Scanner in = new Scanner(System.in); - System.out.println("Hello " + in.nextLine()); + public void run() { + try { + String line = ui.sendInput(); + meal.addMeal(line); + } catch (DateTimeParseException e) { + System.out.println("Please type in the correct date and time format!"); + } catch (NumberFormatException e) { + System.out.println("Please enter the number of calories of the meal properly!"); + } catch (DukeException e) { + System.out.println("My apologies!"); + } + } + + /** + * Main entry-point for the java.duke.Duke application. + */ + public static void main(String[] args) { + new Duke().run(); } } diff --git a/src/main/java/seedu/duke/DukeException.java b/src/main/java/seedu/duke/DukeException.java new file mode 100644 index 0000000000..f9f49e0319 --- /dev/null +++ b/src/main/java/seedu/duke/DukeException.java @@ -0,0 +1,8 @@ +package seedu.duke; + +public class DukeException extends Exception { + public DukeException(String errorMessage) { + super(errorMessage); + System.out.println(errorMessage); + } +} \ No newline at end of file diff --git a/src/main/java/seedu/duke/Meal.java b/src/main/java/seedu/duke/Meal.java new file mode 100644 index 0000000000..9614ff1b8d --- /dev/null +++ b/src/main/java/seedu/duke/Meal.java @@ -0,0 +1,39 @@ +package seedu.duke; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; + +public class Meal { + + protected String[] meals; + protected int mealNumber; + + public Meal() { + this.meals = new String[100]; + this.mealNumber = 0; + } + + public void addMeal(String meal) throws DateTimeParseException,NumberFormatException, DukeException { + String[] userInput = meal.split(" "); + int calorieIndex = userInput.length - 2; + if (calorieIndex <= 1) { + throw new DukeException("Please specify the name of the meal!"); + } + int dateIndex = userInput.length - 1; + int calories = Integer.parseInt(userInput[calorieIndex]); + String mealDescription = userInput[1]; + for (int i = 2 ; i < calorieIndex ; i ++) { + mealDescription = mealDescription.concat(" " + userInput[i]); + } + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + String date = userInput[dateIndex]; + LocalDate localDate = LocalDate.parse(date, formatter); + System.out.println("Noted! CLI.ckFit has recorded your meal of " + mealDescription + " on " + + formatter.format(localDate) + ". " + calories + + " calories has been added to the calorie count!\n"); + meals[mealNumber] = meal; + mealNumber += 1; + } + +} diff --git a/src/main/java/seedu/duke/Ui.java b/src/main/java/seedu/duke/Ui.java new file mode 100644 index 0000000000..b327353874 --- /dev/null +++ b/src/main/java/seedu/duke/Ui.java @@ -0,0 +1,19 @@ +package seedu.duke; + +import java.util.Scanner; + +public class Ui { + + protected Scanner in; + + /** + * Instantiates the Ui object and allows the user to send their commands. + */ + public Ui() { + this.in = new Scanner(System.in); + } + + public String sendInput() { + return in.nextLine(); + } +} From b2449608e90cfaee7b79c263cbfe33ac80ac169d Mon Sep 17 00:00:00 2001 From: VishalJeyaram Date: Thu, 7 Oct 2021 02:06:05 +0800 Subject: [PATCH 019/398] Fixed error in input --- src/main/java/seedu/duke/Meal.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/seedu/duke/Meal.java b/src/main/java/seedu/duke/Meal.java index 9614ff1b8d..42651f8bc0 100644 --- a/src/main/java/seedu/duke/Meal.java +++ b/src/main/java/seedu/duke/Meal.java @@ -20,6 +20,9 @@ public void addMeal(String meal) throws DateTimeParseException,NumberFormatExcep if (calorieIndex <= 1) { throw new DukeException("Please specify the name of the meal!"); } + if (!(userInput[0].equals("ate"))) { + throw new DukeException("Please type in \"ate\" at the beginning!"); + } int dateIndex = userInput.length - 1; int calories = Integer.parseInt(userInput[calorieIndex]); String mealDescription = userInput[1]; From 8e53bc2832907cdaf598c1053336405e888e8252 Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Thu, 7 Oct 2021 02:06:24 +0800 Subject: [PATCH 020/398] add fluid intake capabilities v1.0 --- src/main/java/seedu/duke/Duke.java | 47 ++++++++++++++++++++++++++--- src/main/java/seedu/duke/Fluid.java | 22 ++++++++++++++ 2 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/main/java/seedu/duke/Fluid.java diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 5c74e68d59..290cd91b14 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,8 +1,33 @@ package seedu.duke; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Scanner; public class Duke { + + @SuppressWarnings("FieldCanBeLocal") + private static Fluid fluid; + + public static void sayDrank(String input) { //drank coca cola 300 17/10/2021 + String[] arrayString = input.split(" "); + int lastIndex = arrayString.length - 1; //date + int secondLastIndex = arrayString.length - 2; //volume + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + String dateTime = arrayString[lastIndex]; + LocalDate localDate = LocalDate.parse(dateTime, formatter); + System.out.println("Date Entered: " + formatter.format(localDate) + "\n"); + String fluidDescription = arrayString[1]; + for (int i = 2; i < secondLastIndex; i++) { + fluidDescription = fluidDescription.concat(" " + arrayString[i]); + } + int volume = Integer.parseInt(arrayString[secondLastIndex]); + String date = arrayString[lastIndex]; + fluid = new Fluid(fluidDescription, volume, date); + fluid.toPrint(); + } + /** * Main entry-point for the java.duke.Duke application. */ @@ -12,10 +37,24 @@ public static void main(String[] args) { + "| | | | | | | |/ / _ \\\n" + "| |_| | |_| | < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); - System.out.println("What is your name?"); + System.out.println("Hello from\n" + logo + "\n"); + System.out.println("Enter your wish: " + "\n"); + Scanner scan = new Scanner(System.in); + String input = scan.nextLine(); + String actionWord = input.split(" ")[0]; - Scanner in = new Scanner(System.in); - System.out.println("Hello " + in.nextLine()); + switch (actionWord) { + case "bye": + System.exit(0); + break; + case "drank": + try { + sayDrank(input); + } catch (DateTimeParseException e) { + System.out.println("Please enter in the format: drank [fluid name] [volume] [dd/yy/yyyy]"); + } + break; + default: + } } } diff --git a/src/main/java/seedu/duke/Fluid.java b/src/main/java/seedu/duke/Fluid.java new file mode 100644 index 0000000000..8361836de9 --- /dev/null +++ b/src/main/java/seedu/duke/Fluid.java @@ -0,0 +1,22 @@ +package seedu.duke; + +public class Fluid { + + protected String fluidName; + protected int volume; + protected String date; + + protected String[] fluidArray; + + //constructor + public Fluid(String description, int volume, String date) { + fluidArray = new String[100]; + this.fluidName = description; + this.volume = volume; + this.date = date; + } + + public void toPrint() { + System.out.println("Noted! CLI.ckFit has recorded your drink of " + fluidName + " of " + volume + " ml on " + date + "." + "\n"); + } +} From 8ed7288343f250ecd400142a0c60ea9d8e886b01 Mon Sep 17 00:00:00 2001 From: arvejw Date: Thu, 7 Oct 2021 14:53:47 +0800 Subject: [PATCH 021/398] Change GymManager implementation Parse within method --- src/main/java/seedu/duke/Duke.java | 6 ++++++ src/main/java/seedu/duke/gym/GymManager.java | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 5c74e68d59..a5f6165682 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,5 +1,7 @@ package seedu.duke; +import seedu.duke.gym.GymManager; + import java.util.Scanner; public class Duke { @@ -17,5 +19,9 @@ public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Hello " + in.nextLine()); + + GymManager gm = new GymManager(); + gm.addGymWorkout("chest day /at 12pm"); + gm.doneGymWorkout("chest day /at 12pm /c 356"); } } diff --git a/src/main/java/seedu/duke/gym/GymManager.java b/src/main/java/seedu/duke/gym/GymManager.java index 3b1c31a1dd..466e1409c9 100644 --- a/src/main/java/seedu/duke/gym/GymManager.java +++ b/src/main/java/seedu/duke/gym/GymManager.java @@ -13,6 +13,25 @@ public GymManager() { completedGymWorkoutList = new ArrayList(); } + public void addGymWorkout(String input) { + String[] arguments = input.trim().split("/at", 2); + gymScheduleList.add(new GymWorkout(arguments[0].trim(), arguments[1].trim())); + System.out.println("Noted! CLI.ckFit has scheduled your workout of " + arguments[0].trim() + + " at " + arguments[1].trim() + "."); + } + + public void doneGymWorkout(String input) { + String[] arguments = input.trim().split("/at", 2); + String[] arguments2 = arguments[1].trim().split("/c", 2); + int calories = Integer.parseInt(arguments2[1].trim()); + completedGymWorkoutList.add( + new CompletedGymWorkout(arguments[0].trim(), arguments2[0].trim(), calories) + ); + System.out.println("Noted! CLI.ckFit has recorded your workout of " + arguments[0].trim() + + " at " + arguments2[0].trim() + ". " + calories + " calories have been burned. Keep working!"); + } + + // not for 08/10 public void addGymWorkout(String activityDescription, String activityAt) { gymScheduleList.add(new GymWorkout(activityDescription, activityAt)); } From 762cdc99c9518a238311e6b6c17cdf11cc1a0a89 Mon Sep 17 00:00:00 2001 From: arvejw Date: Thu, 7 Oct 2021 14:56:31 +0800 Subject: [PATCH 022/398] Minor tweak and comments --- src/main/java/seedu/duke/Duke.java | 4 ---- src/main/java/seedu/duke/gym/GymManager.java | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index a5f6165682..63cfeb52e6 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -19,9 +19,5 @@ public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Hello " + in.nextLine()); - - GymManager gm = new GymManager(); - gm.addGymWorkout("chest day /at 12pm"); - gm.doneGymWorkout("chest day /at 12pm /c 356"); } } diff --git a/src/main/java/seedu/duke/gym/GymManager.java b/src/main/java/seedu/duke/gym/GymManager.java index 466e1409c9..26dd811c0d 100644 --- a/src/main/java/seedu/duke/gym/GymManager.java +++ b/src/main/java/seedu/duke/gym/GymManager.java @@ -13,6 +13,7 @@ public GymManager() { completedGymWorkoutList = new ArrayList(); } + // e.g. workoutschedule chest day /at 12pm public void addGymWorkout(String input) { String[] arguments = input.trim().split("/at", 2); gymScheduleList.add(new GymWorkout(arguments[0].trim(), arguments[1].trim())); @@ -20,6 +21,7 @@ public void addGymWorkout(String input) { " at " + arguments[1].trim() + "."); } + // e.g. workout chest day /at 12pm /c 356 public void doneGymWorkout(String input) { String[] arguments = input.trim().split("/at", 2); String[] arguments2 = arguments[1].trim().split("/c", 2); From d41b5cf216ce0e0f4aaecc19a2aa497b55f24211 Mon Sep 17 00:00:00 2001 From: arvejw Date: Thu, 7 Oct 2021 15:01:02 +0800 Subject: [PATCH 023/398] Fix checkstyle errors --- src/main/java/seedu/duke/gym/GymManager.java | 63 ++++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/src/main/java/seedu/duke/gym/GymManager.java b/src/main/java/seedu/duke/gym/GymManager.java index 26dd811c0d..80bcd04c40 100644 --- a/src/main/java/seedu/duke/gym/GymManager.java +++ b/src/main/java/seedu/duke/gym/GymManager.java @@ -17,8 +17,12 @@ public GymManager() { public void addGymWorkout(String input) { String[] arguments = input.trim().split("/at", 2); gymScheduleList.add(new GymWorkout(arguments[0].trim(), arguments[1].trim())); - System.out.println("Noted! CLI.ckFit has scheduled your workout of " + arguments[0].trim() + - " at " + arguments[1].trim() + "."); + System.out.println("Noted! CLI.ckFit has scheduled your workout of " + arguments[0].trim() + + " at " + arguments[1].trim() + "."); + } + + public void addGymWorkout(String activityDescription, String activityAt) { + gymScheduleList.add(new GymWorkout(activityDescription, activityAt)); } // e.g. workout chest day /at 12pm /c 356 @@ -29,36 +33,8 @@ public void doneGymWorkout(String input) { completedGymWorkoutList.add( new CompletedGymWorkout(arguments[0].trim(), arguments2[0].trim(), calories) ); - System.out.println("Noted! CLI.ckFit has recorded your workout of " + arguments[0].trim() + - " at " + arguments2[0].trim() + ". " + calories + " calories have been burned. Keep working!"); - } - - // not for 08/10 - public void addGymWorkout(String activityDescription, String activityAt) { - gymScheduleList.add(new GymWorkout(activityDescription, activityAt)); - } - - public void deleteGymWorkout(int workoutNumber) { - // short circuit if empty - if (gymScheduleList.isEmpty()) { - System.out.println("List is empty"); - return; - } - if (isWorkoutNumberWithinRange(workoutNumber)) { - gymScheduleList.remove(workoutNumber - OFFSET_BY_1); - } else { - System.out.println("Invalid Activity number"); - } - } - - public boolean isWorkoutNumberWithinRange(int workoutNumber) { - //short circuit if empty - if (gymScheduleList.isEmpty()) { - return false; - } - int upperBound = gymScheduleList.size(); - int lowerBound = LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING; // equals 1 - return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound) ? true : false; + System.out.println("Noted! CLI.ckFit has recorded your workout of " + arguments[0].trim() + + " at " + arguments2[0].trim() + ". " + calories + " calories have been burned. Keep working!"); } // if activity exists in schedule list can use activity number @@ -86,6 +62,29 @@ public void doneGymWorkout(String workoutDescription, String workoutAt, int calo ); } + public void deleteGymWorkout(int workoutNumber) { + // short circuit if empty + if (gymScheduleList.isEmpty()) { + System.out.println("List is empty"); + return; + } + if (isWorkoutNumberWithinRange(workoutNumber)) { + gymScheduleList.remove(workoutNumber - OFFSET_BY_1); + } else { + System.out.println("Invalid Activity number"); + } + } + + public boolean isWorkoutNumberWithinRange(int workoutNumber) { + //short circuit if empty + if (gymScheduleList.isEmpty()) { + return false; + } + int upperBound = gymScheduleList.size(); + int lowerBound = LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING; // equals 1 + return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound) ? true : false; + } + public void deleteCompletedGymWorkout(int activityWorkout) { // short circuit if empty if (completedGymWorkoutList.isEmpty()) { From 94b7facd356bcbe2e41722b1e55c539a403e52c6 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Thu, 7 Oct 2021 15:42:44 +0800 Subject: [PATCH 024/398] add command manager --- src/main/java/seedu/duke/CommandManager.java | 71 ++++++++++++++++++++ src/main/java/seedu/duke/Duke.java | 11 ++- src/main/java/seedu/duke/Keywords.java | 12 ++++ src/main/java/seedu/duke/TaskList.java | 4 ++ src/main/java/seedu/duke/Ui.java | 4 ++ 5 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 src/main/java/seedu/duke/CommandManager.java create mode 100644 src/main/java/seedu/duke/Keywords.java create mode 100644 src/main/java/seedu/duke/TaskList.java create mode 100644 src/main/java/seedu/duke/Ui.java diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java new file mode 100644 index 0000000000..5bee942cac --- /dev/null +++ b/src/main/java/seedu/duke/CommandManager.java @@ -0,0 +1,71 @@ +package seedu.duke; +import seedu.duke.gym.GymManager; + +import java.util.Scanner; + +public class CommandManager { + GymManager GM = new GymManager(); + + public void commandChecker() { + String input; + Scanner in = new Scanner(System.in); + input = in.nextLine(); + String[] result = input.trim().split(" ", 2); + String command = result[0]; + + + while (!(command.equals(Keywords.INPUT_BYE))) { + + if (command.equals(Keywords.INPUT_MEAL)) { + //input = mealInputCommand(input, in); + + } else if (command.equals(Keywords.INPUT_WORKOUT)) { + //input = workoutInputCommand(input, in); + GM.doneGymWorkout(result[1]); + + } else if (command.equals(Keywords.INPUT_WORKOUT_SCHEDULE)) { + //input = workoutInputCommand(input, in); + GM.addGymWorkout(result[1]); + + } else if (command.equals(Keywords.INPUT_DRINKS)) { + //input = drinksInputCommand(input, in); + + } else if (command.equals(Keywords.INPUT_ADD_WEIGHT)) { + //input = addweightInputCommand(input, in); + + } else if (command.equals(Keywords.INPUT_CHECK_WEIGHT)) { + //input = checkweightInputCommand(input, in); + + } else { + System.out.println("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");//overall error check + } + input = in.nextLine(); + result = input.trim().split(" ", 2); + command = result[0]; + + } + System.out.println(" Bye! Hope to see you again soon!"); + + } + +// private static String mealInputCommand(String input, Scanner in){ +// Task whatMeal = TaskList.getMealMethod(input); +// System.out.println("Noted! CLI.ckFit has recorded your meal of" + +// [calories kcal] + "has been added to the calorie count!"); +// return input; +// } +// private static String drinksInputCommand(String input, Scanner in){ +// return input; +// } +// private static String workoutInputCommand(String input, Scanner in){ +// return input; +// } +// private static String addweightInputCommand(String input, Scanner in){ +// return input; +// } +// private static String checkweightInputCommand(String input, Scanner in){ +// return input; +// } + + +} \ No newline at end of file diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 63cfeb52e6..ff11c954c4 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,13 +1,10 @@ package seedu.duke; - import seedu.duke.gym.GymManager; import java.util.Scanner; public class Duke { - /** - * Main entry-point for the java.duke.Duke application. - */ + public static void main(String[] args) { String logo = " ____ _ \n" + "| _ \\ _ _| | _____ \n" @@ -15,9 +12,9 @@ public static void main(String[] args) { + "| |_| | |_| | < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; System.out.println("Hello from\n" + logo); - System.out.println("What is your name?"); + System.out.println("What is your command?"); - Scanner in = new Scanner(System.in); - System.out.println("Hello " + in.nextLine()); + CommandManager commandManager = new CommandManager(); + commandManager.commandChecker(); } } diff --git a/src/main/java/seedu/duke/Keywords.java b/src/main/java/seedu/duke/Keywords.java new file mode 100644 index 0000000000..aa2b571ad7 --- /dev/null +++ b/src/main/java/seedu/duke/Keywords.java @@ -0,0 +1,12 @@ +package seedu.duke; + +public class Keywords { + public static final String INPUT_MEAL = "ate"; + public static final String INPUT_WORKOUT = "workout"; + public static final String INPUT_WORKOUT_SCHEDULE = "schedule"; + public static final String INPUT_DRINKS = "drank"; + public static final String INPUT_ADD_WEIGHT = "addweight"; + public static final String INPUT_CHECK_WEIGHT = "checkweight"; + public static final String INPUT_BYE = "bye"; + +} \ No newline at end of file diff --git a/src/main/java/seedu/duke/TaskList.java b/src/main/java/seedu/duke/TaskList.java new file mode 100644 index 0000000000..14b80f388a --- /dev/null +++ b/src/main/java/seedu/duke/TaskList.java @@ -0,0 +1,4 @@ +package seedu.duke; + +public class TaskList { +} diff --git a/src/main/java/seedu/duke/Ui.java b/src/main/java/seedu/duke/Ui.java new file mode 100644 index 0000000000..af12edfc84 --- /dev/null +++ b/src/main/java/seedu/duke/Ui.java @@ -0,0 +1,4 @@ +package seedu.duke; + +public class Ui { +} From 8d8b2d3410a9656bff00df5c3893e0492727d634 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Thu, 7 Oct 2021 15:53:36 +0800 Subject: [PATCH 025/398] gradle edits --- src/main/java/seedu/duke/CommandManager.java | 28 +++----------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index 5bee942cac..c219fb42ef 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -1,10 +1,10 @@ package seedu.duke; -import seedu.duke.gym.GymManager; +import seedu.duke.gym.GymManager; import java.util.Scanner; public class CommandManager { - GymManager GM = new GymManager(); + GymManager gymManager = new GymManager(); public void commandChecker() { String input; @@ -21,11 +21,11 @@ public void commandChecker() { } else if (command.equals(Keywords.INPUT_WORKOUT)) { //input = workoutInputCommand(input, in); - GM.doneGymWorkout(result[1]); + gymManager.doneGymWorkout(result[1]); } else if (command.equals(Keywords.INPUT_WORKOUT_SCHEDULE)) { //input = workoutInputCommand(input, in); - GM.addGymWorkout(result[1]); + gymManager.addGymWorkout(result[1]); } else if (command.equals(Keywords.INPUT_DRINKS)) { //input = drinksInputCommand(input, in); @@ -48,24 +48,4 @@ public void commandChecker() { } -// private static String mealInputCommand(String input, Scanner in){ -// Task whatMeal = TaskList.getMealMethod(input); -// System.out.println("Noted! CLI.ckFit has recorded your meal of" + -// [calories kcal] + "has been added to the calorie count!"); -// return input; -// } -// private static String drinksInputCommand(String input, Scanner in){ -// return input; -// } -// private static String workoutInputCommand(String input, Scanner in){ -// return input; -// } -// private static String addweightInputCommand(String input, Scanner in){ -// return input; -// } -// private static String checkweightInputCommand(String input, Scanner in){ -// return input; -// } - - } \ No newline at end of file From 3dc972d7b3a6cba4eab3b21e29caa05058da9231 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Thu, 7 Oct 2021 16:00:47 +0800 Subject: [PATCH 026/398] edit --- src/main/java/seedu/duke/CommandManager.java | 1 + src/main/java/seedu/duke/Duke.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index c219fb42ef..837d462e9b 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -1,6 +1,7 @@ package seedu.duke; import seedu.duke.gym.GymManager; + import java.util.Scanner; public class CommandManager { diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index ff11c954c4..e523fb4c35 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,4 +1,5 @@ package seedu.duke; + import seedu.duke.gym.GymManager; import java.util.Scanner; From fa1579ccc8f6be97269233aaf4eddeffc09407a2 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Thu, 7 Oct 2021 16:07:08 +0800 Subject: [PATCH 027/398] edits --- src/main/java/seedu/duke/Duke.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index e523fb4c35..7194770c24 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,9 +1,5 @@ package seedu.duke; -import seedu.duke.gym.GymManager; - -import java.util.Scanner; - public class Duke { public static void main(String[] args) { From 003d47df6a312cbafd6b952a0d9752f1f0e19b92 Mon Sep 17 00:00:00 2001 From: VishalJeyaram Date: Thu, 7 Oct 2021 16:24:09 +0800 Subject: [PATCH 028/398] ArrayList added to Meal --- src/main/java/seedu/duke/Meal.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/duke/Meal.java b/src/main/java/seedu/duke/Meal.java index 42651f8bc0..d9c804a22d 100644 --- a/src/main/java/seedu/duke/Meal.java +++ b/src/main/java/seedu/duke/Meal.java @@ -3,14 +3,14 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.util.ArrayList; public class Meal { - - protected String[] meals; + protected ArrayList meals; protected int mealNumber; public Meal() { - this.meals = new String[100]; + this.meals = new ArrayList<>(); this.mealNumber = 0; } @@ -35,7 +35,7 @@ public void addMeal(String meal) throws DateTimeParseException,NumberFormatExcep System.out.println("Noted! CLI.ckFit has recorded your meal of " + mealDescription + " on " + formatter.format(localDate) + ". " + calories + " calories has been added to the calorie count!\n"); - meals[mealNumber] = meal; + meals.add(meal); mealNumber += 1; } From 837e8861bde52907c191874153a3bf7b30f29d2d Mon Sep 17 00:00:00 2001 From: teoziyiivy <69446729+teoziyiivy@users.noreply.github.com> Date: Thu, 7 Oct 2021 16:57:22 +0800 Subject: [PATCH 029/398] Update Duke.java --- src/main/java/seedu/duke/Duke.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 4292cd075b..e5b94c03ed 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -7,7 +7,8 @@ public class Duke { public static ArrayList weights = new ArrayList<>(); public static void printAddWeightResponse() { - System.out.println("Noted! CLI.ckFit has recorded your weight as " + weights.get(weights.size() - 1).getWeight() + ". Check back for your progress!"); + System.out.println("Noted! CLI.ckFit has recorded your weight as " + weights.get(weights.size() - 1).getWeight() + + ". Check back for your progress!"); } public static void printAddWeightException() { From f8d474799010abe75210a2e8fc8848441dfca845 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Thu, 7 Oct 2021 18:27:42 +0800 Subject: [PATCH 030/398] added weight and command manager --- src/main/java/seedu/duke/CommandManager.java | 8 ++- src/main/java/seedu/duke/Duke.java | 71 ++------------------ src/main/java/seedu/duke/Fluid.java | 10 ++- src/main/java/seedu/duke/Meal.java | 10 +-- src/main/java/seedu/duke/WeightTracker.java | 58 +++++++++++++--- 5 files changed, 70 insertions(+), 87 deletions(-) diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index 2c46d8bac9..20e3669882 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -8,11 +8,13 @@ public class CommandManager { protected GymManager gymManager; protected Meal meal; protected Fluid fluid; + protected WeightTracker weightTracker; - public CommandManager(Fluid fluid, Meal meal, GymManager gymManager) { + public CommandManager(Fluid fluid, Meal meal, GymManager gymManager, WeightTracker weightTracker) { this.fluid = fluid; this.meal = meal; this.gymManager = gymManager; + this.weightTracker = weightTracker; } public void commandChecker() { @@ -38,10 +40,10 @@ public void commandChecker() { fluid.sayDrank(input); } else if (command.equals(Keywords.INPUT_ADD_WEIGHT)) { - //input = addweightInputCommand(input, in); + weightTracker.readInput(input); } else if (command.equals(Keywords.INPUT_CHECK_WEIGHT)) { - //input = checkweightInputCommand(input, in); + weightTracker.readInput(input); } else { System.out.println("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");//overall error check diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index aaa802fe68..0f063b53d4 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,79 +1,15 @@ package seedu.duke; - -import java.util.ArrayList; -import java.util.Scanner; - -public class Duke { - public static ArrayList weights = new ArrayList<>(); - - public static void printAddWeightResponse() { - System.out.println("Noted! CLI.ckFit has recorded your weight as " + weights.get(weights.size() - 1).getWeight() - + ". Check back for your progress!"); - } - - public static void printAddWeightException() { - System.out.println("There was a problem adding your weight."); - } - - public static void addWeight(String line) throws AddWeightException { - if (!line.matches("(.*) (.*)")) { - throw new AddWeightException(); - } else { - //extracting the weight and date - String weight = line.replaceAll(" .+", ""); - String date = line.replaceAll(".+ ", ""); - weights.add(new WeightTracker(weight, date)); - printAddWeightResponse(); - } - } - - public static void printWeight() { - System.out.println("Here are your recorded weights:"); - for (int i = 0; i < weights.size(); i++) { - weights.get(i).checkWeight(); - } - - } - - public static void readInput(String line) { - String[] splitLine = line.split(" ", 2); - String command = splitLine[0]; - line = line.replaceAll("^" + command + " ", ""); - if (command.equals("checkweight")) { - printWeight(); - } else if (command.equals("saveweight")) { - try { - addWeight(line); - } catch (AddWeightException e) { - printAddWeightException(); - } - } - } - - public static void main(String[] args) { - String line; - Scanner in = new Scanner(System.in); - line = in.nextLine(); - //continue to run program unless types "bye" to exit program - while (!line.equals("bye")) { - readInput(line); - line = in.nextLine(); - } -======= import seedu.duke.gym.GymManager; -import java.time.format.DateTimeParseException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Scanner; - +@SuppressWarnings("ALL") public class Duke { private Meal meal; private Ui ui; private Fluid fluid; private GymManager gymManager; + private WeightTracker weightTracker; private CommandManager commandManager; @@ -90,7 +26,8 @@ public Duke() { ui = new Ui(); fluid = new Fluid(); gymManager = new GymManager(); - commandManager = new CommandManager(fluid,meal,gymManager); + weightTracker = new WeightTracker(); + commandManager = new CommandManager(fluid, meal, gymManager, weightTracker); } public void run() { diff --git a/src/main/java/seedu/duke/Fluid.java b/src/main/java/seedu/duke/Fluid.java index 129df18d01..47255f3646 100644 --- a/src/main/java/seedu/duke/Fluid.java +++ b/src/main/java/seedu/duke/Fluid.java @@ -16,7 +16,13 @@ public Fluid() { } public void toPrint(String fluidName, int volume, String date) { - System.out.println("Noted! CLI.ckFit has recorded your drink of " + fluidName + " of " + volume + " ml on " + date + "." + "\n"); + System.out.println("Noted! CLI.ckFit has recorded your drink of " + + fluidName + + " of " + + volume + + " ml on " + + date + "." + + "\n"); } public void sayDrank(String input) { //drank coca cola 300 17/10/2021 @@ -34,5 +40,7 @@ public void sayDrank(String input) { //drank coca cola 300 17/10/2 int volume = Integer.parseInt(arrayString[secondLastIndex]); String date = arrayString[lastIndex]; toPrint(fluidDescription, volume, date); + fluidArray.add(input); + numberOfFluids += 1; } } diff --git a/src/main/java/seedu/duke/Meal.java b/src/main/java/seedu/duke/Meal.java index d88339d82c..7a2fcbc205 100644 --- a/src/main/java/seedu/duke/Meal.java +++ b/src/main/java/seedu/duke/Meal.java @@ -14,7 +14,7 @@ public Meal() { this.mealNumber = 0; } - public void addMeal(String meal) throws DateTimeParseException,NumberFormatException { + public void addMeal(String meal) throws DateTimeParseException, NumberFormatException { String[] userInput = meal.split(" "); int calorieIndex = userInput.length - 2; /* @@ -28,15 +28,15 @@ public void addMeal(String meal) throws DateTimeParseException,NumberFormatExcep int dateIndex = userInput.length - 1; int calories = Integer.parseInt(userInput[calorieIndex]); String mealDescription = userInput[1]; - for (int i = 2 ; i < calorieIndex ; i ++) { + for (int i = 2; i < calorieIndex; i++) { mealDescription = mealDescription.concat(" " + userInput[i]); } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); String date = userInput[dateIndex]; LocalDate localDate = LocalDate.parse(date, formatter); - System.out.println("Noted! CLI.ckFit has recorded your meal of " + mealDescription + " on " - + formatter.format(localDate) + ". " + calories + - " calories has been added to the calorie count!\n"); + System.out.println("Noted! CLI.ckFit has recorded your meal of " + + mealDescription + " on " + formatter.format(localDate) + + ". " + calories + " calories has been added to the calorie count!\n"); meals.add(meal); mealNumber += 1; } diff --git a/src/main/java/seedu/duke/WeightTracker.java b/src/main/java/seedu/duke/WeightTracker.java index dc1513561d..71dcee6a92 100644 --- a/src/main/java/seedu/duke/WeightTracker.java +++ b/src/main/java/seedu/duke/WeightTracker.java @@ -1,23 +1,59 @@ package seedu.duke; +import java.util.ArrayList; + public class WeightTracker { - private String weight; - private String date; + protected ArrayList weightsArray; + protected int numberOfWeights; + + + public WeightTracker() { + this.weightsArray = new ArrayList<>(); + this.numberOfWeights = 0; + } + + public void readInput(String input) { + String[] splitLine = input.split(" ", 2); + String command = splitLine[0]; + input = input.replaceAll("^" + command + " ", ""); + if (command.equals("checkweight")) { + printWeight(); + } else if (command.equals("addweight")) { + try { + addWeight(input); + } catch (AddWeightException e) { + printAddWeightException(); + } + } + } - public WeightTracker(String weight, String date) { - this.weight = weight; - this.date = date; + public void printAddWeightResponse(String weight, String date) { + System.out.println("Noted! CLI.ckFit has recorded your weight as " + + weight + " on " + date + ". Check back for your progress!"); } - public String getWeight() { - return weight; + public void printAddWeightException() { + System.out.println("There was a problem adding your weight."); } - public String getDate() { - return date; + public void addWeight(String input) throws AddWeightException { + if (!input.matches("(.*) (.*)")) { + throw new AddWeightException(); + } else { + //extracting the weight and date + String weight = input.replaceAll(" .+", ""); + String date = input.replaceAll(".+ ", ""); + //weights.add(new WeightTracker(weight, date)); + printAddWeightResponse(weight, date); + weightsArray.add(input); + numberOfWeights += 1; + } } - public void checkWeight() { - System.out.println("Your weight was " + getWeight() + " on " + getDate() + "."); + public void printWeight() { + System.out.println("Here are your recorded weights:"); + for (String a : weightsArray) { + System.out.println(a); + } } } From d21d9e420988db000122efb7cd0097f357a726fe Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Thu, 7 Oct 2021 21:23:35 +0800 Subject: [PATCH 031/398] add command manager --- text-ui-test/EXPECTED.TXT | 7 ------- text-ui-test/input.txt | 4 ---- 2 files changed, 11 deletions(-) diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 0c70e674b6..e69de29bb2 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,7 +0,0 @@ -Noted! CLI.ckFit has recorded your weight as 50. Check back for your progress! -Here are your recorded weights: -Your weight was 50 on 9/6/2021. -Noted! CLI.ckFit has recorded your weight as 40. Check back for your progress! -Here are your recorded weights: -Your weight was 50 on 9/6/2021. -Your weight was 40 on 10/6/2021. \ No newline at end of file diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index 983c0f6684..e69de29bb2 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -1,4 +0,0 @@ -saveweight 50 9/6/2021 -checkweight -saveweight 40 10/6/2021 -checkweight \ No newline at end of file From 5ddc73d586774e7cc2ecccd2e02a8a83bdb5bb77 Mon Sep 17 00:00:00 2001 From: arvejw Date: Thu, 7 Oct 2021 21:54:22 +0800 Subject: [PATCH 032/398] Add JUnit for doneGymWorkout exception --- src/main/java/seedu/duke/gym/GymManager.java | 2 +- src/test/java/seedu/duke/gym/GymManagerTest.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/test/java/seedu/duke/gym/GymManagerTest.java diff --git a/src/main/java/seedu/duke/gym/GymManager.java b/src/main/java/seedu/duke/gym/GymManager.java index 80bcd04c40..e9cfcc81dc 100644 --- a/src/main/java/seedu/duke/gym/GymManager.java +++ b/src/main/java/seedu/duke/gym/GymManager.java @@ -13,7 +13,7 @@ public GymManager() { completedGymWorkoutList = new ArrayList(); } - // e.g. workoutschedule chest day /at 12pm + // e.g. schedule chest day /at 12pm public void addGymWorkout(String input) { String[] arguments = input.trim().split("/at", 2); gymScheduleList.add(new GymWorkout(arguments[0].trim(), arguments[1].trim())); diff --git a/src/test/java/seedu/duke/gym/GymManagerTest.java b/src/test/java/seedu/duke/gym/GymManagerTest.java new file mode 100644 index 0000000000..e442bacb70 --- /dev/null +++ b/src/test/java/seedu/duke/gym/GymManagerTest.java @@ -0,0 +1,16 @@ +package seedu.duke.gym; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class GymManagerTest { + + @Test + // test for exception thrown in event of non-integer input for calories + void doneGymWorkout_non_integer_input(){ + GymManager gm = new GymManager(); + String input = "chest day /at 23:59 /c $@$!"; + assertThrows(NumberFormatException.class, () -> gm.doneGymWorkout(input)); + } +} From 19741a0a160639a9c327e64ac63cad538c32932f Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Thu, 7 Oct 2021 22:05:18 +0800 Subject: [PATCH 033/398] Add JUnit testing for fluid intake --- src/main/java/seedu/duke/Fluid.java | 15 ++++----------- src/test/java/seedu/duke/FluidTest.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 src/test/java/seedu/duke/FluidTest.java diff --git a/src/main/java/seedu/duke/Fluid.java b/src/main/java/seedu/duke/Fluid.java index 47255f3646..2be1240b35 100644 --- a/src/main/java/seedu/duke/Fluid.java +++ b/src/main/java/seedu/duke/Fluid.java @@ -9,26 +9,19 @@ public class Fluid { protected ArrayList fluidArray; protected int numberOfFluids; - //constructor public Fluid() { this.fluidArray = new ArrayList<>(); this.numberOfFluids = 0; } public void toPrint(String fluidName, int volume, String date) { - System.out.println("Noted! CLI.ckFit has recorded your drink of " - + fluidName - + " of " - + volume - + " ml on " - + date + "." - + "\n"); + System.out.println("Noted! CLI.ckFit has recorded your drink of " + fluidName + " of " + volume + " ml on " + date + "." + "\n"); } - public void sayDrank(String input) { //drank coca cola 300 17/10/2021 + public void sayDrank(String input) { String[] arrayString = input.split(" "); - int lastIndex = arrayString.length - 1; //date - int secondLastIndex = arrayString.length - 2; //volume + int lastIndex = arrayString.length - 1; + int secondLastIndex = arrayString.length - 2; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); String dateTime = arrayString[lastIndex]; LocalDate localDate = LocalDate.parse(dateTime, formatter); diff --git a/src/test/java/seedu/duke/FluidTest.java b/src/test/java/seedu/duke/FluidTest.java new file mode 100644 index 0000000000..b178c81bdc --- /dev/null +++ b/src/test/java/seedu/duke/FluidTest.java @@ -0,0 +1,17 @@ +package seedu.duke; + +import org.junit.jupiter.api.Test; + +import java.time.format.DateTimeParseException; + +import static org.junit.jupiter.api.Assertions.*; + +class FluidTest { + + @Test + void sayDrank() { + Fluid fluid = new Fluid(); + String input = "drank cola 300 12/12/2021"; + assertThrows(DateTimeParseException.class, () -> fluid.sayDrank(input)); + } +} From c18c2355699b98fe476a67e97248e841995ee9a1 Mon Sep 17 00:00:00 2001 From: arvejw Date: Thu, 7 Oct 2021 22:11:27 +0800 Subject: [PATCH 034/398] Edit for checkstyle --- src/test/java/seedu/duke/gym/GymManagerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/seedu/duke/gym/GymManagerTest.java b/src/test/java/seedu/duke/gym/GymManagerTest.java index e442bacb70..3ef02b132b 100644 --- a/src/test/java/seedu/duke/gym/GymManagerTest.java +++ b/src/test/java/seedu/duke/gym/GymManagerTest.java @@ -2,13 +2,13 @@ import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; class GymManagerTest { @Test // test for exception thrown in event of non-integer input for calories - void doneGymWorkout_non_integer_input(){ + void doneGymWorkout_non_integer_input() { GymManager gm = new GymManager(); String input = "chest day /at 23:59 /c $@$!"; assertThrows(NumberFormatException.class, () -> gm.doneGymWorkout(input)); From c29ab6b6f852f5889d3d3fb73adeca325543b316 Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Thu, 7 Oct 2021 22:12:35 +0800 Subject: [PATCH 035/398] Add JUnit testing for Fluid intake --- src/main/java/seedu/duke/Fluid.java | 3 ++- src/test/java/seedu/duke/FluidTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/duke/Fluid.java b/src/main/java/seedu/duke/Fluid.java index 2be1240b35..86d4a44433 100644 --- a/src/main/java/seedu/duke/Fluid.java +++ b/src/main/java/seedu/duke/Fluid.java @@ -15,7 +15,8 @@ public Fluid() { } public void toPrint(String fluidName, int volume, String date) { - System.out.println("Noted! CLI.ckFit has recorded your drink of " + fluidName + " of " + volume + " ml on " + date + "." + "\n"); + System.out.println("Noted! CLI.ckFit has recorded your drink of " + fluidName + " of " + volume + + " ml on " + date + "." + "\n"); } public void sayDrank(String input) { diff --git a/src/test/java/seedu/duke/FluidTest.java b/src/test/java/seedu/duke/FluidTest.java index b178c81bdc..55e1a906bd 100644 --- a/src/test/java/seedu/duke/FluidTest.java +++ b/src/test/java/seedu/duke/FluidTest.java @@ -4,7 +4,8 @@ import java.time.format.DateTimeParseException; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; + class FluidTest { From 7be349b6b8e176008fcdec2dc9d137cc73639c04 Mon Sep 17 00:00:00 2001 From: arvejw Date: Thu, 7 Oct 2021 22:34:14 +0800 Subject: [PATCH 036/398] Edit whitespace problems in logo --- src/main/java/seedu/duke/Duke.java | 4 ++-- text-ui-test/EXPECTED.TXT | 11 +++++++++++ text-ui-test/input.txt | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 0f063b53d4..464d95a7a8 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -14,8 +14,8 @@ public class Duke { public Duke() { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" + String logo = " ____ _\n" + + "| _ \\ _ _| | _____\n" + "| | | | | | | |/ / _ \\\n" + "| |_| | |_| | < __/\n" + "|____/ \\__,_|_|\\_\\___|\n"; diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index e69de29bb2..7d79659ab6 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -0,0 +1,11 @@ +Hello from + ____ _ +| _ \ _ _| | _____ +| | | | | | | |/ / _ \ +| |_| | |_| | < __/ +|____/ \__,_|_|\_\___| + + +What is your command? +☹ OOPS!!! I'm sorry, but I don't know what that means :-( + Bye! Hope to see you again soon! diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index e69de29bb2..386a968044 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -0,0 +1,2 @@ +hi +bye \ No newline at end of file From 67af5fd88aa5ab5e9afa526f367f54eab58840b4 Mon Sep 17 00:00:00 2001 From: VishalJeyaram Date: Thu, 7 Oct 2021 22:43:11 +0800 Subject: [PATCH 037/398] JUnit added for Meal class methods --- src/test/java/seedu/duke/MealTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/java/seedu/duke/MealTest.java diff --git a/src/test/java/seedu/duke/MealTest.java b/src/test/java/seedu/duke/MealTest.java new file mode 100644 index 0000000000..64009d7cea --- /dev/null +++ b/src/test/java/seedu/duke/MealTest.java @@ -0,0 +1,16 @@ +package seedu.duke; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class MealTest { + + @Test + void addMeal() { + Meal meal = new Meal(); + String input = "ate pasta 14/09/2021"; + Assertions.assertThrows(NumberFormatException.class, () -> { + meal.addMeal(input); + }); + } +} \ No newline at end of file From 2db3da86af36d24f2905a8ccd4d76b7e58990916 Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Thu, 7 Oct 2021 22:52:22 +0800 Subject: [PATCH 038/398] Add JUnit testing --- src/main/java/seedu/duke/Duke.java | 2 -- src/test/java/seedu/duke/FluidTest.java | 1 - 2 files changed, 3 deletions(-) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 464d95a7a8..90089ba847 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -12,7 +12,6 @@ public class Duke { private WeightTracker weightTracker; private CommandManager commandManager; - public Duke() { String logo = " ____ _\n" + "| _ \\ _ _| | _____\n" @@ -34,7 +33,6 @@ public void run() { commandManager.commandChecker(); } - public static void main(String[] args) { new Duke().run(); } diff --git a/src/test/java/seedu/duke/FluidTest.java b/src/test/java/seedu/duke/FluidTest.java index 55e1a906bd..f538354d34 100644 --- a/src/test/java/seedu/duke/FluidTest.java +++ b/src/test/java/seedu/duke/FluidTest.java @@ -6,7 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; - class FluidTest { @Test From 81f560a63ede75cbd0d7df7357c8107e7acba512 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Fri, 8 Oct 2021 02:06:20 +0800 Subject: [PATCH 039/398] Add junit test for command checker --- .../java/seedu/duke/CommandManagerTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/java/seedu/duke/CommandManagerTest.java diff --git a/src/test/java/seedu/duke/CommandManagerTest.java b/src/test/java/seedu/duke/CommandManagerTest.java new file mode 100644 index 0000000000..289e7ebf20 --- /dev/null +++ b/src/test/java/seedu/duke/CommandManagerTest.java @@ -0,0 +1,37 @@ +package seedu.duke; + +import org.junit.jupiter.api.Test; + +class CommandManagerTest { + @Test + void commandManager() { + String input = "drank cola 300 12/12/2021"; + String[] result = input.trim().split(" ", 2); + String command = result[0]; + assert command.equals("drank"); + } + + @Test + void commandManager1() { + String input = "workout leg day /at 23:59 /c 388"; + String[] result = input.trim().split(" ", 2); + String command = result[0]; + assert command.equals("workout"); + } + + @Test + void commandManager2() { + String input = "ate risotto and noodle 200 12/12/2022"; + String[] result = input.trim().split(" ", 2); + String command = result[0]; + assert command.equals("ate"); + } + + @Test + void commandManager3() { + String input = "addweight 30 12/12/2021"; + String[] result = input.trim().split(" ", 2); + String command = result[0]; + assert command.equals("addweight"); + } +} \ No newline at end of file From 0ba5f319fd699010f9663ebab8bd7307085246e9 Mon Sep 17 00:00:00 2001 From: teoziyiivy Date: Fri, 8 Oct 2021 09:01:52 +0800 Subject: [PATCH 040/398] Add j-unit test for adding weight --- src/main/java/seedu/duke/Duke.java | 3 ++- src/test/java/seedu/duke/WeightTrackerTest.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/test/java/seedu/duke/WeightTrackerTest.java diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 4292cd075b..fd3f02c9ff 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -7,7 +7,8 @@ public class Duke { public static ArrayList weights = new ArrayList<>(); public static void printAddWeightResponse() { - System.out.println("Noted! CLI.ckFit has recorded your weight as " + weights.get(weights.size() - 1).getWeight() + ". Check back for your progress!"); + System.out.println("Noted! CLI.ckFit has recorded your weight as " + weights.get(weights.size() - 1).getWeight() + + ". Check back for your progress!"); } public static void printAddWeightException() { diff --git a/src/test/java/seedu/duke/WeightTrackerTest.java b/src/test/java/seedu/duke/WeightTrackerTest.java new file mode 100644 index 0000000000..f8a2aa0d83 --- /dev/null +++ b/src/test/java/seedu/duke/WeightTrackerTest.java @@ -0,0 +1,15 @@ +package seedu.duke; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class WeightTrackerTest { + + @Test + void addWeight() { + String input = "addweight 50 08/10/2021"; + Assertions.assertThrows(NumberFormatException.class, () -> { + Duke.addWeight(input); + }); + } +} From 6c9e6c9f64b721182c4c33295643b9fe8333b91f Mon Sep 17 00:00:00 2001 From: arvejw Date: Fri, 8 Oct 2021 15:01:12 +0800 Subject: [PATCH 041/398] Change logo and I/O test --- src/main/java/seedu/duke/Duke.java | 11 ++++++----- text-ui-test/EXPECTED.TXT | 11 +++++++++++ text-ui-test/input.txt | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 0f063b53d4..8c917c1c9b 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -14,11 +14,12 @@ public class Duke { public Duke() { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; + String logo = " ______ _____ _____ __ ________ _ _\n" + + " .' ___ ||_ _| |_ _| [ | _ |_ __ |(_) / |_\n" + + "/ .' \\_| | | | | .---. | | / ] | |_ \\_|__ `| |-'\n" + + "| | | | _ | | / /'`\\] | '' < | _| [ | | |\n" + + "\\ `.___.'\\ _| |__/ | _| |_ _ | \\__. | |`\\ \\ _| |_ | | | |,\n" + + " `.____ .'|________||_____|(_)'.___.'[__| \\_]|_____| [___]\\__/"; System.out.println("Hello from\n" + logo + "\n"); System.out.println("What is your command?"); diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index e69de29bb2..28b6e38661 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -0,0 +1,11 @@ +Hello from + ______ _____ _____ __ ________ _ _ + .' ___ ||_ _| |_ _| [ | _ |_ __ |(_) / |_ +/ .' \_| | | | | .---. | | / ] | |_ \_|__ `| |-' +| | | | _ | | / /'`\] | '' < | _| [ | | | +\ `.___.'\ _| |__/ | _| |_ _ | \__. | |`\ \ _| |_ | | | |, + `.____ .'|________||_____|(_)'.___.'[__| \_]|_____| [___]\__/ + +What is your command? +☹ OOPS!!! I'm sorry, but I don't know what that means :-( + Bye! Hope to see you again soon! \ No newline at end of file diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index e69de29bb2..386a968044 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -0,0 +1,2 @@ +hi +bye \ No newline at end of file From 6298fe08c39c6a1af9904f6d22bdb81d37c7c9c1 Mon Sep 17 00:00:00 2001 From: arvejw Date: Fri, 8 Oct 2021 15:30:15 +0800 Subject: [PATCH 042/398] Edit some JUnit due to CI failure --- src/test/java/seedu/duke/FluidTest.java | 2 +- src/test/java/seedu/duke/WeightTrackerTest.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/java/seedu/duke/FluidTest.java b/src/test/java/seedu/duke/FluidTest.java index 55e1a906bd..3f47472c92 100644 --- a/src/test/java/seedu/duke/FluidTest.java +++ b/src/test/java/seedu/duke/FluidTest.java @@ -12,7 +12,7 @@ class FluidTest { @Test void sayDrank() { Fluid fluid = new Fluid(); - String input = "drank cola 300 12/12/2021"; + String input = "drank cola 300 12-12-2021"; assertThrows(DateTimeParseException.class, () -> fluid.sayDrank(input)); } } diff --git a/src/test/java/seedu/duke/WeightTrackerTest.java b/src/test/java/seedu/duke/WeightTrackerTest.java index 09983e77d7..09d80cc05f 100644 --- a/src/test/java/seedu/duke/WeightTrackerTest.java +++ b/src/test/java/seedu/duke/WeightTrackerTest.java @@ -8,9 +8,7 @@ public class WeightTrackerTest { @Test void addWeight() { WeightTracker weights = new WeightTracker(); - String input = "addweight 50 08/10/2021"; - Assertions.assertThrows(NumberFormatException.class, () -> { - weights.addWeight(input); - }); + String input = "addweight"; + Assertions.assertThrows(AddWeightException.class, () -> weights.addWeight(input)); } } From 54d178100e343b6e6d5173f64d996bb796aac10d Mon Sep 17 00:00:00 2001 From: arvejw Date: Fri, 8 Oct 2021 21:31:40 +0800 Subject: [PATCH 043/398] Add minimal classes for parser --- src/main/java/seedu/duke/InvalidArgumentException.java | 7 +++++++ src/main/java/seedu/duke/InvalidSeparatorException.java | 7 +++++++ src/main/java/seedu/duke/Parser.java | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/main/java/seedu/duke/InvalidArgumentException.java create mode 100644 src/main/java/seedu/duke/InvalidSeparatorException.java create mode 100644 src/main/java/seedu/duke/Parser.java diff --git a/src/main/java/seedu/duke/InvalidArgumentException.java b/src/main/java/seedu/duke/InvalidArgumentException.java new file mode 100644 index 0000000000..05d4321dbc --- /dev/null +++ b/src/main/java/seedu/duke/InvalidArgumentException.java @@ -0,0 +1,7 @@ +package seedu.duke; + +public class InvalidArgumentException extends Exception { + public String getMessage() { + return "Invalid arguments encountered, please enter valid arguments!"; + } +} diff --git a/src/main/java/seedu/duke/InvalidSeparatorException.java b/src/main/java/seedu/duke/InvalidSeparatorException.java new file mode 100644 index 0000000000..503eca0f55 --- /dev/null +++ b/src/main/java/seedu/duke/InvalidSeparatorException.java @@ -0,0 +1,7 @@ +package seedu.duke; + +public class InvalidSeparatorException extends Exception { + public String getMessage() { + return "Invalid separator encountered, please enter a valid separator!"; + } +} diff --git a/src/main/java/seedu/duke/Parser.java b/src/main/java/seedu/duke/Parser.java new file mode 100644 index 0000000000..6102d2e5f6 --- /dev/null +++ b/src/main/java/seedu/duke/Parser.java @@ -0,0 +1,8 @@ +package seedu.duke; + +public class Parser { + + public static int parseStringToInteger(String input) throws NumberFormatException { + return Integer.parseInt(input); + } +} From 5973ef60405cfc0c41cac21ad991dbce48bf06a6 Mon Sep 17 00:00:00 2001 From: VishalJeyaram Date: Fri, 8 Oct 2021 22:27:18 +0800 Subject: [PATCH 044/398] Parser updated and parent class created --- src/main/java/seedu/duke/CommandManager.java | 12 ++-- src/main/java/seedu/duke/Meal.java | 30 +++++--- src/main/java/seedu/duke/Parser.java | 75 ++++++++++++++++++++ src/main/java/seedu/duke/Tracker.java | 4 ++ 4 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 src/main/java/seedu/duke/Tracker.java diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index 20e3669882..bd3e298353 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -21,8 +21,8 @@ public void commandChecker() { String input; Scanner in = new Scanner(System.in); input = in.nextLine(); - String[] result = input.trim().split(" ", 2); - String command = result[0]; + String[] inputArguments = input.trim().split(" ", 2); + String command = inputArguments[0]; while (!(command.equals(Keywords.INPUT_BYE))) { @@ -31,10 +31,10 @@ public void commandChecker() { meal.addMeal(input); } else if (command.equals(Keywords.INPUT_WORKOUT)) { - gymManager.doneGymWorkout(result[1]); + gymManager.doneGymWorkout(inputArguments[1]); } else if (command.equals(Keywords.INPUT_WORKOUT_SCHEDULE)) { - gymManager.addGymWorkout(result[1]); + gymManager.addGymWorkout(inputArguments[1]); } else if (command.equals(Keywords.INPUT_DRINKS)) { fluid.sayDrank(input); @@ -49,8 +49,8 @@ public void commandChecker() { System.out.println("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");//overall error check } input = in.nextLine(); - result = input.trim().split(" ", 2); - command = result[0]; + inputArguments = input.trim().split(" ", 2); + command = inputArguments[0]; } System.out.println(" Bye! Hope to see you again soon!"); diff --git a/src/main/java/seedu/duke/Meal.java b/src/main/java/seedu/duke/Meal.java index 7a2fcbc205..c1508bbc64 100644 --- a/src/main/java/seedu/duke/Meal.java +++ b/src/main/java/seedu/duke/Meal.java @@ -1,30 +1,42 @@ package seedu.duke; import java.time.LocalDate; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.ArrayList; -public class Meal { +public class Meal extends Tracker{ protected ArrayList meals; protected int mealNumber; + protected int calories; + protected String description; + protected LocalDate date; + protected LocalTime time; public Meal() { this.meals = new ArrayList<>(); this.mealNumber = 0; } + public void generateMealParameters(String inputArguments) { + try { + calories = Parser.getCalories(inputArguments); + description = Parser.getDescription(inputArguments); + date = Parser.getDate(inputArguments); + time = Parser.getTime(inputArguments); + } catch (NumberFormatException e) { + + } catch (DukeException e) { + + } catch (DateTimeParseException e) { + + } + } + public void addMeal(String meal) throws DateTimeParseException, NumberFormatException { String[] userInput = meal.split(" "); int calorieIndex = userInput.length - 2; - /* - if (calorieIndex <= 1) { - throw new DukeException("Please specify the name of the meal!"); - } - if (!(userInput[0].equals("ate"))) { - throw new DukeException("Please type in \"ate\" at the beginning!"); - } - */ int dateIndex = userInput.length - 1; int calories = Integer.parseInt(userInput[calorieIndex]); String mealDescription = userInput[1]; diff --git a/src/main/java/seedu/duke/Parser.java b/src/main/java/seedu/duke/Parser.java index 6102d2e5f6..64acfbc850 100644 --- a/src/main/java/seedu/duke/Parser.java +++ b/src/main/java/seedu/duke/Parser.java @@ -1,8 +1,83 @@ package seedu.duke; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.Locale; + public class Parser { public static int parseStringToInteger(String input) throws NumberFormatException { return Integer.parseInt(input); } + + public static int getCalories(String inputArguments) throws DukeException { + String[] userInput = inputArguments.split(" "); + int length = userInput.length; + int calories = 0; + for (int i = 1; i < length ; i++) { + if (userInput[i].equals("/c")) { + calories = parseStringToInteger(userInput[i+1]); + break; + } + } + if (calories < 0) { + throw new DukeException("Negative calories"); + } + return calories; + } + + public static String getDescription(String inputArguments) throws DukeException { + String[] userInput = inputArguments.split(" /c "); + String description = userInput[0]; + return description; + } + + public static LocalDate getDate(String inputArguments) throws DukeException, DateTimeParseException { + String[] userInput = inputArguments.split(" "); + int length = userInput.length; + String date = ""; + for (int i = 1; i < length ; i++) { + if (userInput[i].equals("/d")) { + date = userInput[i+1]; + break; + } + } + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + return LocalDate.parse(date, formatter); + } + + public static LocalTime getTime(String inputArguments) throws DukeException, DateTimeParseException { + String[] userInput = inputArguments.split(" "); + int length = userInput.length; + String time = ""; + for (int i = 1; i < length ; i++) { + if (userInput[i].equals("/t")) { + time = userInput[i+1]; + break; + } + } + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mma"); + return LocalTime.parse(time, formatter); + } + + public static int getWeight(String inputArguments) throws DukeException { + String[] userInput = inputArguments.split(" /d "); + int weight = parseStringToInteger(userInput[0]); + if (weight < 0) { + throw new DukeException("Negative weight"); + } + return weight; + } + + public static String getScheduleDescription(String inputArguments) throws DukeException { + String[] userInput = inputArguments.split(" /d "); + String description = userInput[0]; + return description; + } + + + + } diff --git a/src/main/java/seedu/duke/Tracker.java b/src/main/java/seedu/duke/Tracker.java new file mode 100644 index 0000000000..e267d5e90e --- /dev/null +++ b/src/main/java/seedu/duke/Tracker.java @@ -0,0 +1,4 @@ +package seedu.duke; + +public abstract class Tracker { +} From e092fe5ba62c7f831eb8774b64918f8aab4bc289 Mon Sep 17 00:00:00 2001 From: arvejw Date: Fri, 8 Oct 2021 23:50:42 +0800 Subject: [PATCH 045/398] Tweak and add functions for other gym related features --- src/main/java/seedu/duke/CommandManager.java | 4 +- src/main/java/seedu/duke/Duke.java | 4 +- .../seedu/duke/InvalidArgumentException.java | 7 - .../seedu/duke/InvalidSeparatorException.java | 7 - src/main/java/seedu/duke/Parser.java | 5 - .../seedu/duke/gym/CompletedGymWorkout.java | 10 +- src/main/java/seedu/duke/gym/GymManager.java | 152 +++++++++--------- src/main/java/seedu/duke/gym/GymWorkout.java | 27 ---- .../seedu/duke/gym/ScheduledGymWorkout.java | 52 ++++++ .../java/seedu/duke/gym/GymManagerTest.java | 2 +- 10 files changed, 143 insertions(+), 127 deletions(-) delete mode 100644 src/main/java/seedu/duke/InvalidArgumentException.java delete mode 100644 src/main/java/seedu/duke/InvalidSeparatorException.java delete mode 100644 src/main/java/seedu/duke/gym/GymWorkout.java create mode 100644 src/main/java/seedu/duke/gym/ScheduledGymWorkout.java diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index bd3e298353..0d47d3867c 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -31,10 +31,10 @@ public void commandChecker() { meal.addMeal(input); } else if (command.equals(Keywords.INPUT_WORKOUT)) { - gymManager.doneGymWorkout(inputArguments[1]); + gymManager.addCompletedWorkout(inputArguments[1]); } else if (command.equals(Keywords.INPUT_WORKOUT_SCHEDULE)) { - gymManager.addGymWorkout(inputArguments[1]); + gymManager.addScheduledWorkout(inputArguments[1]); } else if (command.equals(Keywords.INPUT_DRINKS)) { fluid.sayDrank(input); diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 8c917c1c9b..2287425ef5 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -37,6 +37,8 @@ public void run() { public static void main(String[] args) { - new Duke().run(); + //new Duke().run(); + GymManager gm = new GymManager(); + gm.addScheduledWorkout("chest day /d 17/08/2021 /t 7:59PM"); } } diff --git a/src/main/java/seedu/duke/InvalidArgumentException.java b/src/main/java/seedu/duke/InvalidArgumentException.java deleted file mode 100644 index 05d4321dbc..0000000000 --- a/src/main/java/seedu/duke/InvalidArgumentException.java +++ /dev/null @@ -1,7 +0,0 @@ -package seedu.duke; - -public class InvalidArgumentException extends Exception { - public String getMessage() { - return "Invalid arguments encountered, please enter valid arguments!"; - } -} diff --git a/src/main/java/seedu/duke/InvalidSeparatorException.java b/src/main/java/seedu/duke/InvalidSeparatorException.java deleted file mode 100644 index 503eca0f55..0000000000 --- a/src/main/java/seedu/duke/InvalidSeparatorException.java +++ /dev/null @@ -1,7 +0,0 @@ -package seedu.duke; - -public class InvalidSeparatorException extends Exception { - public String getMessage() { - return "Invalid separator encountered, please enter a valid separator!"; - } -} diff --git a/src/main/java/seedu/duke/Parser.java b/src/main/java/seedu/duke/Parser.java index 64acfbc850..6dfee511c5 100644 --- a/src/main/java/seedu/duke/Parser.java +++ b/src/main/java/seedu/duke/Parser.java @@ -4,7 +4,6 @@ import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; -import java.util.Locale; public class Parser { @@ -76,8 +75,4 @@ public static String getScheduleDescription(String inputArguments) throws DukeEx String description = userInput[0]; return description; } - - - - } diff --git a/src/main/java/seedu/duke/gym/CompletedGymWorkout.java b/src/main/java/seedu/duke/gym/CompletedGymWorkout.java index fb55c31fd4..9e05705c9e 100644 --- a/src/main/java/seedu/duke/gym/CompletedGymWorkout.java +++ b/src/main/java/seedu/duke/gym/CompletedGymWorkout.java @@ -1,10 +1,14 @@ package seedu.duke.gym; -public class CompletedGymWorkout extends GymWorkout { +import java.time.LocalDate; +import java.time.LocalTime; + +public class CompletedGymWorkout extends ScheduledGymWorkout { private int caloriesBurned; - public CompletedGymWorkout(String activityDescription, String activityAt, int caloriesBurned) { - super(activityDescription, activityAt); + public CompletedGymWorkout(String workoutDescription, LocalDate workoutDate, + LocalTime workoutTime, int caloriesBurned) { + super(workoutDescription, workoutDate, workoutTime); this.caloriesBurned = caloriesBurned; } diff --git a/src/main/java/seedu/duke/gym/GymManager.java b/src/main/java/seedu/duke/gym/GymManager.java index e9cfcc81dc..f9d067f094 100644 --- a/src/main/java/seedu/duke/gym/GymManager.java +++ b/src/main/java/seedu/duke/gym/GymManager.java @@ -1,128 +1,132 @@ package seedu.duke.gym; +import seedu.duke.DukeException; +import seedu.duke.Parser; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeParseException; import java.util.ArrayList; public class GymManager { - private ArrayList gymScheduleList; - private ArrayList completedGymWorkoutList; + private ArrayList scheduledWorkoutList; + private ArrayList completedWorkoutList; private static final int LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING = 1; private static final int OFFSET_BY_1 = 1; //OFFSET to convert between 0 & 1's Indexing public GymManager() { - gymScheduleList = new ArrayList(); - completedGymWorkoutList = new ArrayList(); - } - - // e.g. schedule chest day /at 12pm - public void addGymWorkout(String input) { - String[] arguments = input.trim().split("/at", 2); - gymScheduleList.add(new GymWorkout(arguments[0].trim(), arguments[1].trim())); - System.out.println("Noted! CLI.ckFit has scheduled your workout of " + arguments[0].trim() - + " at " + arguments[1].trim() + "."); - } - - public void addGymWorkout(String activityDescription, String activityAt) { - gymScheduleList.add(new GymWorkout(activityDescription, activityAt)); + scheduledWorkoutList = new ArrayList(); + completedWorkoutList = new ArrayList(); } - // e.g. workout chest day /at 12pm /c 356 - public void doneGymWorkout(String input) { - String[] arguments = input.trim().split("/at", 2); - String[] arguments2 = arguments[1].trim().split("/c", 2); - int calories = Integer.parseInt(arguments2[1].trim()); - completedGymWorkoutList.add( - new CompletedGymWorkout(arguments[0].trim(), arguments2[0].trim(), calories) - ); - System.out.println("Noted! CLI.ckFit has recorded your workout of " + arguments[0].trim() - + " at " + arguments2[0].trim() + ". " + calories + " calories have been burned. Keep working!"); + public void addScheduledWorkout(String inputArguments) { + try { + String workoutDescription = Parser.getScheduleDescription(inputArguments); + LocalDate workoutDate = Parser.getDate(inputArguments); + LocalTime workoutTime = Parser.getTime(inputArguments); + scheduledWorkoutList.add( + new ScheduledGymWorkout(workoutDescription, workoutDate, workoutTime) + ); + } catch (DukeException e) { + } catch (DateTimeParseException e) { + System.out.println(e.getMessage()); + } } - // if activity exists in schedule list can use activity number - // once date/time properly implemented only workouts on the current date can be "done" - public void doneGymWorkout(int workoutNumber, int caloriesBurned) { - //short circuit if empty - if (gymScheduleList.isEmpty()) { - System.out.println("List is empty"); - return; - } - if (isWorkoutNumberWithinRange(workoutNumber)) { - completedGymWorkoutList.add( - new CompletedGymWorkout(gymScheduleList.get(workoutNumber - OFFSET_BY_1).getWorkoutDescription(), - gymScheduleList.get(workoutNumber - OFFSET_BY_1).getWorkoutAt(), caloriesBurned) + public void addCompletedWorkout(String inputArguments) { + try { + String workoutDescription = Parser.getDescription(inputArguments); + int caloriesBurned = Parser.getCalories(inputArguments); + LocalDate workoutDate = Parser.getDate(inputArguments); + LocalTime workoutTime = Parser.getTime(inputArguments); + completedWorkoutList.add( + new CompletedGymWorkout(workoutDescription, workoutDate, workoutTime, caloriesBurned) ); - } else { - System.out.println("Invalid Activity number"); + } catch (DukeException e) { + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + } catch (DateTimeParseException e) { + System.out.println(e.getMessage()); } } - // completing activity that is not in gym schedule - public void doneGymWorkout(String workoutDescription, String workoutAt, int caloriesBurned) { - completedGymWorkoutList.add( - new CompletedGymWorkout(workoutDescription, workoutAt, caloriesBurned) - ); + public boolean isWorkoutNumberWithinRange(int workoutNumber) { + //short circuit if empty + if (scheduledWorkoutList.isEmpty()) { + return false; + } + int upperBound = scheduledWorkoutList.size(); + int lowerBound = LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING; + return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound) ? true : false; } - public void deleteGymWorkout(int workoutNumber) { + public void deleteScheduledWorkout(String inputArguments) { // short circuit if empty - if (gymScheduleList.isEmpty()) { + if (scheduledWorkoutList.isEmpty()) { System.out.println("List is empty"); return; } + int workoutNumber; + try { + workoutNumber = Parser.parseStringToInteger(inputArguments); + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return; + } if (isWorkoutNumberWithinRange(workoutNumber)) { - gymScheduleList.remove(workoutNumber - OFFSET_BY_1); + scheduledWorkoutList.remove(workoutNumber - OFFSET_BY_1); } else { - System.out.println("Invalid Activity number"); + System.out.println("Failed to delete that workout! Please enter an Integer within range."); } } - public boolean isWorkoutNumberWithinRange(int workoutNumber) { - //short circuit if empty - if (gymScheduleList.isEmpty()) { - return false; - } - int upperBound = gymScheduleList.size(); - int lowerBound = LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING; // equals 1 - return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound) ? true : false; - } - - public void deleteCompletedGymWorkout(int activityWorkout) { + public void deleteCompletedGymWorkout(String inputArguments) { // short circuit if empty - if (completedGymWorkoutList.isEmpty()) { + if (completedWorkoutList.isEmpty()) { System.out.println("List is empty"); return; } - if (isWorkoutNumberWithinRange(activityWorkout)) { - completedGymWorkoutList.remove(activityWorkout - OFFSET_BY_1); + int workoutNumber; + try { + workoutNumber = Parser.parseStringToInteger(inputArguments); + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return; + } + if (isWorkoutNumberWithinRange(workoutNumber)) { + completedWorkoutList.remove(workoutNumber - OFFSET_BY_1); } else { - System.out.println("Invalid Activity number"); + System.out.println("Failed to delete that workout! Please enter an Integer within range."); } } - public void printGymSchedule() { + public void listScheduledWorkouts() { // short circuit if empty - if (gymScheduleList.isEmpty()) { - System.out.println("List is empty"); + if (scheduledWorkoutList.isEmpty()) { + System.out.println("Sorry but your scheduled workout list is empty!"); return; } int currentIndex = 1; - for (GymWorkout a : gymScheduleList) { + for (ScheduledGymWorkout s : scheduledWorkoutList) { //placeholder before user interface class implemented - System.out.println(currentIndex + ". " + a.getWorkoutDescription() + "(at: " + a.getWorkoutAt() + ")"); + System.out.println(currentIndex + ". " + s.getWorkoutDescription() + "(at: " + + s.getWorkoutDate().toString() + " " + s.getWorkoutTime().toString() + ")"); currentIndex++; } } public void printCompletedGymWorkouts() { // short circuit if empty - if (completedGymWorkoutList.isEmpty()) { - System.out.println("Completed list is empty"); + if (completedWorkoutList.isEmpty()) { + System.out.println("Sorry but your completed workout list is empty!"); return; } int currentIndex = 1; - for (CompletedGymWorkout a : completedGymWorkoutList) { + for (CompletedGymWorkout c : completedWorkoutList) { //placeholder before user interface class implemented - System.out.println(currentIndex + ". " + a.getWorkoutDescription() + "(at: " + a.getWorkoutAt() - + ")(calories burned: " + a.getCaloriesBurned() + ")"); + System.out.println(currentIndex + ". " + c.getWorkoutDescription() + "(at: " + + c.getWorkoutDate().toString() + " " + c.getWorkoutTime().toString() + ")(calories burned: " + + c.getCaloriesBurned() + ")"); currentIndex++; } } diff --git a/src/main/java/seedu/duke/gym/GymWorkout.java b/src/main/java/seedu/duke/gym/GymWorkout.java deleted file mode 100644 index 59f154b20e..0000000000 --- a/src/main/java/seedu/duke/gym/GymWorkout.java +++ /dev/null @@ -1,27 +0,0 @@ -package seedu.duke.gym; - -public class GymWorkout { - private String workoutDescription; - private String workoutAt; //todo: store as DateTime instead of String - - public GymWorkout(String workoutDescription, String workoutAt) { - this.workoutDescription = workoutDescription; - this.workoutAt = workoutAt; - } - - public String getWorkoutDescription() { - return workoutDescription; - } - - public void setWorkoutDescription(String workoutDescription) { - this.workoutDescription = workoutDescription; - } - - public String getWorkoutAt() { - return workoutAt; - } - - public void setWorkoutAt(String workoutAt) { - this.workoutAt = workoutAt; - } -} diff --git a/src/main/java/seedu/duke/gym/ScheduledGymWorkout.java b/src/main/java/seedu/duke/gym/ScheduledGymWorkout.java new file mode 100644 index 0000000000..fb8da7d8bb --- /dev/null +++ b/src/main/java/seedu/duke/gym/ScheduledGymWorkout.java @@ -0,0 +1,52 @@ +package seedu.duke.gym; + +import seedu.duke.Tracker; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; + +public class ScheduledGymWorkout extends Tracker { + private String workoutDescription; + private LocalDate workoutDate; + private LocalTime workoutTime; + private LocalDateTime workoutDateTime; + public ScheduledGymWorkout(String workoutDescription, LocalDate workoutDate, LocalTime workoutTime) { + this.workoutDescription = workoutDescription; + this.workoutDate = workoutDate; + this.workoutTime = workoutTime; + this.workoutDateTime = LocalDateTime.of(workoutDate, workoutTime); + } + + public String getWorkoutDescription() { + return workoutDescription; + } + + public void setWorkoutDescription(String workoutDescription) { + this. workoutDescription = workoutDescription; + } + + public LocalDate getWorkoutDate() { + return workoutDate; + } + + public void setWorkoutDate(LocalDate workoutDate) { + this.workoutDate = workoutDate; + } + + public LocalTime getWorkoutTime() { + return workoutTime; + } + + public void setWorkoutTime(LocalTime workoutTime) { + this.workoutTime = workoutTime; + } + + public LocalDateTime getWorkoutDateTime() { + return workoutDateTime; + } + + public void setWorkoutDateTime(LocalDateTime workoutDateTime) { + this.workoutDateTime = workoutDateTime; + } +} diff --git a/src/test/java/seedu/duke/gym/GymManagerTest.java b/src/test/java/seedu/duke/gym/GymManagerTest.java index 3ef02b132b..d751d71065 100644 --- a/src/test/java/seedu/duke/gym/GymManagerTest.java +++ b/src/test/java/seedu/duke/gym/GymManagerTest.java @@ -11,6 +11,6 @@ class GymManagerTest { void doneGymWorkout_non_integer_input() { GymManager gm = new GymManager(); String input = "chest day /at 23:59 /c $@$!"; - assertThrows(NumberFormatException.class, () -> gm.doneGymWorkout(input)); + assertThrows(NumberFormatException.class, () -> gm.addCompletedWorkout(input)); } } From 7ef029d0f4d0b7d0ec7b60e29579bb0e06b569c1 Mon Sep 17 00:00:00 2001 From: arvejw Date: Sat, 9 Oct 2021 03:05:54 +0800 Subject: [PATCH 046/398] Rename some classes --- .../{CompletedGymWorkout.java => CompletedWorkout.java} | 6 +++--- .../{ScheduledGymWorkout.java => ScheduledWorkout.java} | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) rename src/main/java/seedu/duke/gym/{CompletedGymWorkout.java => CompletedWorkout.java} (65%) rename src/main/java/seedu/duke/gym/{ScheduledGymWorkout.java => ScheduledWorkout.java} (82%) diff --git a/src/main/java/seedu/duke/gym/CompletedGymWorkout.java b/src/main/java/seedu/duke/gym/CompletedWorkout.java similarity index 65% rename from src/main/java/seedu/duke/gym/CompletedGymWorkout.java rename to src/main/java/seedu/duke/gym/CompletedWorkout.java index 9e05705c9e..afb874235d 100644 --- a/src/main/java/seedu/duke/gym/CompletedGymWorkout.java +++ b/src/main/java/seedu/duke/gym/CompletedWorkout.java @@ -3,11 +3,11 @@ import java.time.LocalDate; import java.time.LocalTime; -public class CompletedGymWorkout extends ScheduledGymWorkout { +public class CompletedWorkout extends ScheduledWorkout { private int caloriesBurned; - public CompletedGymWorkout(String workoutDescription, LocalDate workoutDate, - LocalTime workoutTime, int caloriesBurned) { + public CompletedWorkout(String workoutDescription, LocalDate workoutDate, + LocalTime workoutTime, int caloriesBurned) { super(workoutDescription, workoutDate, workoutTime); this.caloriesBurned = caloriesBurned; } diff --git a/src/main/java/seedu/duke/gym/ScheduledGymWorkout.java b/src/main/java/seedu/duke/gym/ScheduledWorkout.java similarity index 82% rename from src/main/java/seedu/duke/gym/ScheduledGymWorkout.java rename to src/main/java/seedu/duke/gym/ScheduledWorkout.java index fb8da7d8bb..9c2ec829de 100644 --- a/src/main/java/seedu/duke/gym/ScheduledGymWorkout.java +++ b/src/main/java/seedu/duke/gym/ScheduledWorkout.java @@ -6,12 +6,13 @@ import java.time.LocalDateTime; import java.time.LocalTime; -public class ScheduledGymWorkout extends Tracker { - private String workoutDescription; +public class ScheduledWorkout extends seedu.duke.Tracker { + private String workoutDescription; private LocalDate workoutDate; private LocalTime workoutTime; private LocalDateTime workoutDateTime; - public ScheduledGymWorkout(String workoutDescription, LocalDate workoutDate, LocalTime workoutTime) { + + public ScheduledWorkout(String workoutDescription, LocalDate workoutDate, LocalTime workoutTime) { this.workoutDescription = workoutDescription; this.workoutDate = workoutDate; this.workoutTime = workoutTime; @@ -23,7 +24,7 @@ public String getWorkoutDescription() { } public void setWorkoutDescription(String workoutDescription) { - this. workoutDescription = workoutDescription; + this.workoutDescription = workoutDescription; } public LocalDate getWorkoutDate() { From 42a10d3dcaa46afe935e85560c49460a19b22126 Mon Sep 17 00:00:00 2001 From: arvejw Date: Sat, 9 Oct 2021 03:07:36 +0800 Subject: [PATCH 047/398] Add more helper methods to Parser class --- src/main/java/seedu/duke/Duke.java | 4 +--- src/main/java/seedu/duke/Parser.java | 35 ++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 2287425ef5..8c917c1c9b 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -37,8 +37,6 @@ public void run() { public static void main(String[] args) { - //new Duke().run(); - GymManager gm = new GymManager(); - gm.addScheduledWorkout("chest day /d 17/08/2021 /t 7:59PM"); + new Duke().run(); } } diff --git a/src/main/java/seedu/duke/Parser.java b/src/main/java/seedu/duke/Parser.java index 6dfee511c5..ab08ccca27 100644 --- a/src/main/java/seedu/duke/Parser.java +++ b/src/main/java/seedu/duke/Parser.java @@ -7,6 +7,27 @@ public class Parser { + //todo: replace the separators used in methods below with the final Strings to avoid magic literals + public static final String DATE_SEPARATOR = " /d "; + public static final String TIME_SEPARATOR = " /t "; + public static final String CALORIE_SEPARATOR = " /c "; + public static final String WHITESPACE = " "; + + // the 3 boolean methods below are helper functions to short circuit + // e.g. if you need /c /d /t separators in the input, + // if either /c /d /t are missing you can give user an error message and exit the method + public static boolean containsDateSeparator(String inputArguments) { + return inputArguments.contains(DATE_SEPARATOR); + } + + public static boolean containsTimeSeparator(String inputArguments) { + return inputArguments.contains(TIME_SEPARATOR); + } + + public static boolean containsCalorieSeparator(String inputArguments) { + return inputArguments.contains(CALORIE_SEPARATOR); + } + public static int parseStringToInteger(String input) throws NumberFormatException { return Integer.parseInt(input); } @@ -15,9 +36,9 @@ public static int getCalories(String inputArguments) throws DukeException { String[] userInput = inputArguments.split(" "); int length = userInput.length; int calories = 0; - for (int i = 1; i < length ; i++) { + for (int i = 1; i < length; i++) { if (userInput[i].equals("/c")) { - calories = parseStringToInteger(userInput[i+1]); + calories = parseStringToInteger(userInput[i + 1]); break; } } @@ -37,9 +58,9 @@ public static LocalDate getDate(String inputArguments) throws DukeException, Dat String[] userInput = inputArguments.split(" "); int length = userInput.length; String date = ""; - for (int i = 1; i < length ; i++) { + for (int i = 1; i < length; i++) { if (userInput[i].equals("/d")) { - date = userInput[i+1]; + date = userInput[i + 1]; break; } } @@ -51,9 +72,9 @@ public static LocalTime getTime(String inputArguments) throws DukeException, Dat String[] userInput = inputArguments.split(" "); int length = userInput.length; String time = ""; - for (int i = 1; i < length ; i++) { + for (int i = 1; i < length; i++) { if (userInput[i].equals("/t")) { - time = userInput[i+1]; + time = userInput[i + 1]; break; } } @@ -70,7 +91,7 @@ public static int getWeight(String inputArguments) throws DukeException { return weight; } - public static String getScheduleDescription(String inputArguments) throws DukeException { + public static String getScheduleDescription(String inputArguments) { String[] userInput = inputArguments.split(" /d "); String description = userInput[0]; return description; From 35805f0b8cc5690d7f9d6a027803da892dd761de Mon Sep 17 00:00:00 2001 From: arvejw Date: Sat, 9 Oct 2021 03:08:16 +0800 Subject: [PATCH 048/398] Tweak CommandManager to handle single word inputs correctly --- src/main/java/seedu/duke/CommandManager.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index 0d47d3867c..dbbe492a5d 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -21,9 +21,13 @@ public void commandChecker() { String input; Scanner in = new Scanner(System.in); input = in.nextLine(); - String[] inputArguments = input.trim().split(" ", 2); - String command = inputArguments[0]; - + String[] splitResult = input.trim().split(" ", 2); //todo: maybe also add this to parser class? + String command = splitResult[0]; + // naming/way is implemented can be changed, + // to handle input= oneword e.g "addschedule" which does not split so inputArguments.length will be 1 + // basically this is to avoid accessing inputArguments[1] which is out of bounds + // inputArguments is null if user input < 2 words + String inputArguments = (splitResult.length == 2) ? splitResult[1] : null; while (!(command.equals(Keywords.INPUT_BYE))) { @@ -31,10 +35,10 @@ public void commandChecker() { meal.addMeal(input); } else if (command.equals(Keywords.INPUT_WORKOUT)) { - gymManager.addCompletedWorkout(inputArguments[1]); + gymManager.addCompletedWorkout(inputArguments); } else if (command.equals(Keywords.INPUT_WORKOUT_SCHEDULE)) { - gymManager.addScheduledWorkout(inputArguments[1]); + gymManager.addScheduledWorkout(inputArguments); } else if (command.equals(Keywords.INPUT_DRINKS)) { fluid.sayDrank(input); @@ -49,9 +53,9 @@ public void commandChecker() { System.out.println("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");//overall error check } input = in.nextLine(); - inputArguments = input.trim().split(" ", 2); - command = inputArguments[0]; - + splitResult = input.trim().split(" ", 2); + command = splitResult[0]; + inputArguments = (splitResult.length == 2) ? splitResult[1] : null; } System.out.println(" Bye! Hope to see you again soon!"); From f6605e48c864c68bf1b1afdfc6ec094a40e402e0 Mon Sep 17 00:00:00 2001 From: arvejw Date: Sat, 9 Oct 2021 03:11:52 +0800 Subject: [PATCH 049/398] Add new features to GymManager Some relevent JUnit tests also added --- src/main/java/seedu/duke/gym/GymManager.java | 135 ++++++++++++------ .../java/seedu/duke/gym/GymManagerTest.java | 74 +++++++++- 2 files changed, 165 insertions(+), 44 deletions(-) diff --git a/src/main/java/seedu/duke/gym/GymManager.java b/src/main/java/seedu/duke/gym/GymManager.java index f9d067f094..d389b96113 100644 --- a/src/main/java/seedu/duke/gym/GymManager.java +++ b/src/main/java/seedu/duke/gym/GymManager.java @@ -9,25 +9,64 @@ import java.util.ArrayList; public class GymManager { - private ArrayList scheduledWorkoutList; - private ArrayList completedWorkoutList; + private ArrayList scheduledWorkoutList; + private ArrayList completedWorkoutList; private static final int LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING = 1; private static final int OFFSET_BY_1 = 1; //OFFSET to convert between 0 & 1's Indexing public GymManager() { - scheduledWorkoutList = new ArrayList(); - completedWorkoutList = new ArrayList(); + scheduledWorkoutList = new ArrayList(); + completedWorkoutList = new ArrayList(); + } + + public void nullArgumentCheck(String inputArguments) throws DukeException { + if (inputArguments == null) { + throw new DukeException("Please enter an argument!"); + } + } + + public void scheduledWorkoutSeparatorCheck(String inputArguments) throws DukeException { + boolean areSeparatorsCorrect = Parser.containsDateSeparator(inputArguments) + && Parser.containsTimeSeparator(inputArguments); + if (!areSeparatorsCorrect) { + throw new DukeException("Invalid or missing separator... Please try again!"); + } + } + + public void completedWorkoutSeparatorCheck(String inputArguments) throws DukeException { + boolean areSeparatorsCorrect = Parser.containsCalorieSeparator(inputArguments) + && Parser.containsDateSeparator(inputArguments) + && Parser.containsTimeSeparator(inputArguments); + if (!areSeparatorsCorrect) { + throw new DukeException("Invalid or missing separator... Please try again!"); + } + } + + public void emptyScheduledWorkoutListCheck() throws DukeException { + if (scheduledWorkoutList.isEmpty()) { + throw new DukeException("Completed Workout list is empty!"); + } + } + + public void emptyCompletedWorkoutListCheck() throws DukeException { + if (completedWorkoutList.isEmpty()) { + throw new DukeException("Scheduled Workout list is empty!"); + } } public void addScheduledWorkout(String inputArguments) { try { + nullArgumentCheck(inputArguments); + scheduledWorkoutSeparatorCheck(inputArguments); String workoutDescription = Parser.getScheduleDescription(inputArguments); LocalDate workoutDate = Parser.getDate(inputArguments); LocalTime workoutTime = Parser.getTime(inputArguments); scheduledWorkoutList.add( - new ScheduledGymWorkout(workoutDescription, workoutDate, workoutTime) + new ScheduledWorkout(workoutDescription, workoutDate, workoutTime) ); - } catch (DukeException e) { + System.out.println("Noted! CLI.ckFit has scheduled your workout of " + workoutDescription + + " at " + workoutDate.toString() + " " + workoutTime.toString() + "."); + } catch (DukeException ignored) { // message already output to user } catch (DateTimeParseException e) { System.out.println(e.getMessage()); } @@ -35,14 +74,19 @@ public void addScheduledWorkout(String inputArguments) { public void addCompletedWorkout(String inputArguments) { try { + nullArgumentCheck(inputArguments); + completedWorkoutSeparatorCheck(inputArguments); String workoutDescription = Parser.getDescription(inputArguments); int caloriesBurned = Parser.getCalories(inputArguments); LocalDate workoutDate = Parser.getDate(inputArguments); LocalTime workoutTime = Parser.getTime(inputArguments); completedWorkoutList.add( - new CompletedGymWorkout(workoutDescription, workoutDate, workoutTime, caloriesBurned) + new CompletedWorkout(workoutDescription, workoutDate, workoutTime, caloriesBurned) ); - } catch (DukeException e) { + System.out.println("Noted! CLI.ckFit has recorded your workout of " + workoutDescription + + " at " + workoutDate.toString() + " " + workoutTime.toString() + ". " + caloriesBurned + + " calories have been burned. Keep working!"); + } catch (DukeException ignored) { // message already output to user } catch (NumberFormatException e) { System.out.println(e.getMessage()); } catch (DateTimeParseException e) { @@ -50,50 +94,61 @@ public void addCompletedWorkout(String inputArguments) { } } - public boolean isWorkoutNumberWithinRange(int workoutNumber) { - //short circuit if empty - if (scheduledWorkoutList.isEmpty()) { - return false; - } + // assumes whether list is empty has already been checked beforehand + public boolean isScheduledWorkoutNumberWithinRange(int workoutNumber) { int upperBound = scheduledWorkoutList.size(); int lowerBound = LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING; - return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound) ? true : false; + return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound); + } + + // assumes whether list is empty has already been checked beforehand + public boolean isCompletedWorkoutNumberWithinRange(int workoutNumber) { + int upperBound = completedWorkoutList.size(); + int lowerBound = LOWER_BOUND_INDEX_NON_EMPTY_LIST_ONES_INDEXING; + return (workoutNumber >= lowerBound) && (workoutNumber <= upperBound); } public void deleteScheduledWorkout(String inputArguments) { - // short circuit if empty - if (scheduledWorkoutList.isEmpty()) { - System.out.println("List is empty"); - return; - } - int workoutNumber; + int workoutNumber = 0; try { + nullArgumentCheck(inputArguments); + emptyScheduledWorkoutListCheck(); workoutNumber = Parser.parseStringToInteger(inputArguments); } catch (NumberFormatException e) { System.out.println(e.getMessage()); return; + } catch (DukeException ignored) { //message already output + return; } - if (isWorkoutNumberWithinRange(workoutNumber)) { + if (isScheduledWorkoutNumberWithinRange(workoutNumber)) { + ScheduledWorkout workoutToDelete = scheduledWorkoutList.get(workoutNumber - OFFSET_BY_1); + System.out.println("Noted! CLI.ckFit has successfully deleted your scheduled workout of " + + workoutToDelete.getWorkoutDescription() + " at " + workoutToDelete.getWorkoutDate().toString() + + " " + workoutToDelete.getWorkoutTime().toString() + "!"); scheduledWorkoutList.remove(workoutNumber - OFFSET_BY_1); } else { System.out.println("Failed to delete that workout! Please enter an Integer within range."); } } - public void deleteCompletedGymWorkout(String inputArguments) { - // short circuit if empty - if (completedWorkoutList.isEmpty()) { - System.out.println("List is empty"); - return; - } - int workoutNumber; + public void deleteCompletedWorkout(String inputArguments) { + int workoutNumber = 0; try { + nullArgumentCheck(inputArguments); + emptyCompletedWorkoutListCheck(); workoutNumber = Parser.parseStringToInteger(inputArguments); } catch (NumberFormatException e) { System.out.println(e.getMessage()); return; + } catch (DukeException ignored) { // message already output to user + return; } - if (isWorkoutNumberWithinRange(workoutNumber)) { + if (isCompletedWorkoutNumberWithinRange(workoutNumber)) { + CompletedWorkout workoutToDelete = completedWorkoutList.get(workoutNumber - OFFSET_BY_1); + System.out.println("Noted! CLI.ckFit has successfully deleted your completed workout of " + + workoutToDelete.getWorkoutDescription() + " at " + workoutToDelete.getWorkoutDate().toString() + + " " + workoutToDelete.getWorkoutTime().toString() + " where you burned " + + workoutToDelete.getCaloriesBurned() + " calories!"); completedWorkoutList.remove(workoutNumber - OFFSET_BY_1); } else { System.out.println("Failed to delete that workout! Please enter an Integer within range."); @@ -101,30 +156,30 @@ public void deleteCompletedGymWorkout(String inputArguments) { } public void listScheduledWorkouts() { - // short circuit if empty - if (scheduledWorkoutList.isEmpty()) { - System.out.println("Sorry but your scheduled workout list is empty!"); + try { + emptyScheduledWorkoutListCheck(); + } catch (DukeException ignored) { // message already output to user return; } int currentIndex = 1; - for (ScheduledGymWorkout s : scheduledWorkoutList) { + for (ScheduledWorkout s : scheduledWorkoutList) { //placeholder before user interface class implemented - System.out.println(currentIndex + ". " + s.getWorkoutDescription() + "(at: " + System.out.println(currentIndex + ". " + s.getWorkoutDescription() + " (at: " + s.getWorkoutDate().toString() + " " + s.getWorkoutTime().toString() + ")"); currentIndex++; } } - public void printCompletedGymWorkouts() { - // short circuit if empty - if (completedWorkoutList.isEmpty()) { - System.out.println("Sorry but your completed workout list is empty!"); + public void listCompletedWorkouts() { + try { + emptyCompletedWorkoutListCheck(); + } catch (DukeException ignored) { // message already output to user return; } int currentIndex = 1; - for (CompletedGymWorkout c : completedWorkoutList) { + for (CompletedWorkout c : completedWorkoutList) { //placeholder before user interface class implemented - System.out.println(currentIndex + ". " + c.getWorkoutDescription() + "(at: " + System.out.println(currentIndex + ". " + c.getWorkoutDescription() + " (at: " + c.getWorkoutDate().toString() + " " + c.getWorkoutTime().toString() + ")(calories burned: " + c.getCaloriesBurned() + ")"); currentIndex++; diff --git a/src/test/java/seedu/duke/gym/GymManagerTest.java b/src/test/java/seedu/duke/gym/GymManagerTest.java index d751d71065..6d91809623 100644 --- a/src/test/java/seedu/duke/gym/GymManagerTest.java +++ b/src/test/java/seedu/duke/gym/GymManagerTest.java @@ -2,15 +2,81 @@ import org.junit.jupiter.api.Test; +import seedu.duke.DukeException; + + +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; class GymManagerTest { @Test - // test for exception thrown in event of non-integer input for calories - void doneGymWorkout_non_integer_input() { + void nullArgumentCheck_NullInput() { + GymManager gm = new GymManager(); + String argumentInput = null; + assertThrows(DukeException.class, () -> gm.nullArgumentCheck(argumentInput)); + } + + @Test + void isScheduledWorkoutNumberWithinRange_inputOutOfRangeNegative_failure() { + GymManager gm = new GymManager(); + assertFalse(gm.isScheduledWorkoutNumberWithinRange(-256)); + assertFalse(gm.isScheduledWorkoutNumberWithinRange(0)); + assertFalse(gm.isScheduledWorkoutNumberWithinRange(2)); + assertFalse(gm.isScheduledWorkoutNumberWithinRange(2048)); + } + + + @Test + void isScheduledWorkoutNumberWithinRange_inputWithinRange_success() { + GymManager gm = new GymManager(); + String argumentInput = "test /d 07/07/2021 /t 7:59PM"; + gm.addScheduledWorkout(argumentInput); + assertTrue(gm.isScheduledWorkoutNumberWithinRange(1)); + } + + + @Test + void isCompletedWorkoutNumberWithinRange_inputOutOfRange_failure() { + GymManager gm = new GymManager(); + assertFalse(gm.isCompletedWorkoutNumberWithinRange(-256)); + assertFalse(gm.isCompletedWorkoutNumberWithinRange(0)); + assertFalse(gm.isCompletedWorkoutNumberWithinRange(2)); + assertFalse(gm.isCompletedWorkoutNumberWithinRange(2048)); + } + + @Test + void isCompletedWorkoutNumberWithinRange_inputWithinRange_success() { + GymManager gm = new GymManager(); + String argumentInput = "test /c 123 /d 07/07/2021 /t 7:59PM"; + gm.addCompletedWorkout(argumentInput); + assertTrue(gm.isCompletedWorkoutNumberWithinRange(1)); + } + + @Test + void scheduledWorkoutSeparatorCheck_MissingSeparator_exceptionThrow() { + GymManager gm = new GymManager(); + String argumentInput = "test /d 07/07/2021 7:59PM"; + assertThrows(DukeException.class, () -> gm.scheduledWorkoutSeparatorCheck(argumentInput)); + } + + @Test + void completedWorkoutSeparatorCheck_MissingSeparator_exceptionThrow() { + GymManager gm = new GymManager(); + String argumentInput = "test 123 07/07/2021 7:59PM"; + assertThrows(DukeException.class, () -> gm.scheduledWorkoutSeparatorCheck(argumentInput)); + } + + @Test + void emptyScheduledWorkoutListCheck_emptyList_exceptionThrow() { + GymManager gm = new GymManager(); + assertThrows(DukeException.class, gm::emptyScheduledWorkoutListCheck); + } + + @Test + void emptyCompletedWorkoutListCheck_emptyList_exceptionThrow() { GymManager gm = new GymManager(); - String input = "chest day /at 23:59 /c $@$!"; - assertThrows(NumberFormatException.class, () -> gm.addCompletedWorkout(input)); + assertThrows(DukeException.class, gm::emptyCompletedWorkoutListCheck); } } From 55c71ba848958084ac44bcf32a28fc5e19715a72 Mon Sep 17 00:00:00 2001 From: arvejw Date: Mon, 11 Oct 2021 01:14:01 +0800 Subject: [PATCH 050/398] Minor tweak --- src/main/java/seedu/duke/gym/ScheduledWorkout.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/duke/gym/ScheduledWorkout.java b/src/main/java/seedu/duke/gym/ScheduledWorkout.java index 9c2ec829de..25912c9fd3 100644 --- a/src/main/java/seedu/duke/gym/ScheduledWorkout.java +++ b/src/main/java/seedu/duke/gym/ScheduledWorkout.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; -public class ScheduledWorkout extends seedu.duke.Tracker { +public class ScheduledWorkout extends Tracker { private String workoutDescription; private LocalDate workoutDate; private LocalTime workoutTime; From e730e9bb822fd9f454515ad5b2e025aa22f8d752 Mon Sep 17 00:00:00 2001 From: VishalJeyaram Date: Mon, 11 Oct 2021 04:50:20 +0800 Subject: [PATCH 051/398] Delete and List added --- src/main/java/seedu/duke/CommandManager.java | 8 +-- src/main/java/seedu/duke/Duke.java | 9 +++- src/main/java/seedu/duke/Keywords.java | 3 +- src/main/java/seedu/duke/Meal.java | 54 ++++++++++++-------- src/main/java/seedu/duke/Parser.java | 13 ++--- 5 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index bd3e298353..6ba5fa4512 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -24,12 +24,14 @@ public void commandChecker() { String[] inputArguments = input.trim().split(" ", 2); String command = inputArguments[0]; - while (!(command.equals(Keywords.INPUT_BYE))) { if (command.equals(Keywords.INPUT_MEAL)) { - meal.addMeal(input); - + meal.addMeal(inputArguments[1]); + } else if (command.equals(Keywords.DELETE_MEAL)) { + meal.deleteMeal(inputArguments[1]); + } else if (command.equals(Keywords.LIST_MEAL)) { + meal.listMeals(); } else if (command.equals(Keywords.INPUT_WORKOUT)) { gymManager.doneGymWorkout(inputArguments[1]); diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 8c917c1c9b..cd83b688c2 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -2,6 +2,8 @@ import seedu.duke.gym.GymManager; +import java.time.format.DateTimeParseException; + @SuppressWarnings("ALL") public class Duke { @@ -32,7 +34,12 @@ public Duke() { } public void run() { - commandManager.commandChecker(); + try { + commandManager.commandChecker(); + } catch (DateTimeParseException e) { + System.out.println("date problem"); + } + } diff --git a/src/main/java/seedu/duke/Keywords.java b/src/main/java/seedu/duke/Keywords.java index aa2b571ad7..df4c0288ab 100644 --- a/src/main/java/seedu/duke/Keywords.java +++ b/src/main/java/seedu/duke/Keywords.java @@ -8,5 +8,6 @@ public class Keywords { public static final String INPUT_ADD_WEIGHT = "addweight"; public static final String INPUT_CHECK_WEIGHT = "checkweight"; public static final String INPUT_BYE = "bye"; - + public static final String DELETE_MEAL = "deletemeal"; + public static final String LIST_MEAL = "listmeal"; } \ No newline at end of file diff --git a/src/main/java/seedu/duke/Meal.java b/src/main/java/seedu/duke/Meal.java index c1508bbc64..c1be942c84 100644 --- a/src/main/java/seedu/duke/Meal.java +++ b/src/main/java/seedu/duke/Meal.java @@ -2,7 +2,6 @@ import java.time.LocalDate; import java.time.LocalTime; -import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.ArrayList; @@ -11,12 +10,14 @@ public class Meal extends Tracker{ protected int mealNumber; protected int calories; protected String description; - protected LocalDate date; - protected LocalTime time; + protected String date; + protected String time; + protected int totalCalories; public Meal() { this.meals = new ArrayList<>(); this.mealNumber = 0; + this.totalCalories = 0; } public void generateMealParameters(String inputArguments) { @@ -28,29 +29,42 @@ public void generateMealParameters(String inputArguments) { } catch (NumberFormatException e) { } catch (DukeException e) { - - } catch (DateTimeParseException e) { - + System.out.println("run away"); } } - public void addMeal(String meal) throws DateTimeParseException, NumberFormatException { - String[] userInput = meal.split(" "); - int calorieIndex = userInput.length - 2; - int dateIndex = userInput.length - 1; - int calories = Integer.parseInt(userInput[calorieIndex]); - String mealDescription = userInput[1]; - for (int i = 2; i < calorieIndex; i++) { - mealDescription = mealDescription.concat(" " + userInput[i]); - } - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - String date = userInput[dateIndex]; - LocalDate localDate = LocalDate.parse(date, formatter); + public void addMeal(String inputArguments) throws DateTimeParseException, NumberFormatException { + generateMealParameters(inputArguments); System.out.println("Noted! CLI.ckFit has recorded your meal of " - + mealDescription + " on " + formatter.format(localDate) + + description + " on " + date + " and at " + time + ". " + calories + " calories has been added to the calorie count!\n"); - meals.add(meal); + totalCalories += calories; + meals.add(inputArguments); mealNumber += 1; } + public void deleteMeal(String inputArguments) throws DateTimeParseException, NumberFormatException { + int mealIndex = Parser.parseStringToInteger(inputArguments) - 1; + generateMealParameters(meals.get(mealIndex)); + meals.remove(mealIndex); + mealNumber -= 1; + totalCalories -= calories; + System.out.println(description + " will be removed from your list of meals consumed. You now " + + "have " + totalCalories + " left!\n"); + } + + public void listMeals() throws DateTimeParseException, NumberFormatException { + int i = 1; + for (String meal : meals) { + generateMealParameters(meal); + System.out.println(i + ". " + description); + System.out.println("Calories: " + calories); + System.out.println("Date: " + date); + System.out.println("Time: " + time + "\n"); + i += 1; + } + System.out.println("Total number of meals: " + mealNumber); + System.out.println("Total calories: " + totalCalories); + } + } diff --git a/src/main/java/seedu/duke/Parser.java b/src/main/java/seedu/duke/Parser.java index 64acfbc850..d5df0c4bb4 100644 --- a/src/main/java/seedu/duke/Parser.java +++ b/src/main/java/seedu/duke/Parser.java @@ -4,7 +4,6 @@ import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; -import java.util.Locale; public class Parser { @@ -34,7 +33,7 @@ public static String getDescription(String inputArguments) throws DukeException return description; } - public static LocalDate getDate(String inputArguments) throws DukeException, DateTimeParseException { + public static String getDate(String inputArguments) throws DukeException, DateTimeParseException { String[] userInput = inputArguments.split(" "); int length = userInput.length; String date = ""; @@ -45,10 +44,11 @@ public static LocalDate getDate(String inputArguments) throws DukeException, Dat } } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - return LocalDate.parse(date, formatter); + LocalDate localDate = LocalDate.parse(date, formatter); + return formatter.format(localDate); } - public static LocalTime getTime(String inputArguments) throws DukeException, DateTimeParseException { + public static String getTime(String inputArguments) throws DukeException, DateTimeParseException { String[] userInput = inputArguments.split(" "); int length = userInput.length; String time = ""; @@ -58,8 +58,9 @@ public static LocalTime getTime(String inputArguments) throws DukeException, Dat break; } } - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mma"); - return LocalTime.parse(time, formatter); + LocalTime localTime = LocalTime.parse(time); + String properTime = localTime.format(DateTimeFormatter.ofPattern("h:mma")); + return properTime; } public static int getWeight(String inputArguments) throws DukeException { From c3e2df0e10b78d26d0c5a07134c0396e6a819303 Mon Sep 17 00:00:00 2001 From: pragyan_01 Date: Mon, 11 Oct 2021 04:51:21 +0800 Subject: [PATCH 052/398] add fluid basics: add, delete, list --- src/main/java/seedu/duke/CommandManager.java | 9 ++- src/main/java/seedu/duke/Fluid.java | 76 +++++++++++++------- src/main/java/seedu/duke/Keywords.java | 3 +- src/main/java/seedu/duke/Meal.java | 4 +- src/main/java/seedu/duke/Parser.java | 28 ++++++-- 5 files changed, 85 insertions(+), 35 deletions(-) diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index bd3e298353..12d1955887 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -24,7 +24,6 @@ public void commandChecker() { String[] inputArguments = input.trim().split(" ", 2); String command = inputArguments[0]; - while (!(command.equals(Keywords.INPUT_BYE))) { if (command.equals(Keywords.INPUT_MEAL)) { @@ -37,8 +36,12 @@ public void commandChecker() { gymManager.addGymWorkout(inputArguments[1]); } else if (command.equals(Keywords.INPUT_DRINKS)) { - fluid.sayDrank(input); - + fluid.generateFluidParameters(inputArguments[1]); + fluid.addFluid(inputArguments[1]); + } else if (command.equals(Keywords.DELETE_DRINKS)) { + fluid.deleteFluid(inputArguments[1]); + } else if (command.equals(Keywords.LIST_DRINKS)) { + fluid.listFluid(); } else if (command.equals(Keywords.INPUT_ADD_WEIGHT)) { weightTracker.readInput(input); diff --git a/src/main/java/seedu/duke/Fluid.java b/src/main/java/seedu/duke/Fluid.java index 86d4a44433..4150bf3738 100644 --- a/src/main/java/seedu/duke/Fluid.java +++ b/src/main/java/seedu/duke/Fluid.java @@ -1,40 +1,68 @@ package seedu.duke; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.ArrayList; -public class Fluid { +public class Fluid extends Tracker { protected ArrayList fluidArray; - protected int numberOfFluids; + protected int fluidNumber; + protected String description; + protected int calories; + protected int volume; + protected String date; + protected String time; public Fluid() { this.fluidArray = new ArrayList<>(); - this.numberOfFluids = 0; + this.fluidNumber = 0; } - public void toPrint(String fluidName, int volume, String date) { - System.out.println("Noted! CLI.ckFit has recorded your drink of " + fluidName + " of " + volume - + " ml on " + date + "." + "\n"); + public void generateFluidParameters(String inputArguments) { + try { + description = Parser.getDescription(inputArguments); + calories = Parser.getCalories(inputArguments); + volume = Parser.getVolume(inputArguments); + date = Parser.getDate(inputArguments); + time = Parser.getTime(inputArguments); + } catch (NumberFormatException e) { + + } catch (DukeException e) { + + } catch (DateTimeParseException e) { + + } + } + + public void addFluid(String inputArguments) { //drank cola /c 60 /v 100 /d 12/12/2021 /t 10:30 + fluidArray.add(inputArguments); //drank water /c 0 /v 300 /d 11/11/2021 /t 12:30 + fluidNumber += 1; //drank juice /c 30 /v 75 /d 03/10/2021 /t 22:30 + System.out.println("Noted! CLI.ckFit has recorded your drink of " + description + " of " + calories + + " calories and " + volume + " ml on " + date + " " + time + "." + "\n"); + } + + public void deleteFluid(String inputArguments) { + int taskNumber = Parser.parseStringToInteger(inputArguments) - 1; + generateFluidParameters(fluidArray.get(taskNumber)); + fluidArray.remove(taskNumber); + fluidNumber -= 1; + System.out.println("Noted! CLI.ckFit has deleted your drink of " + description + " of " + calories + + " calories and " + volume + " ml on " + date + " " + time + "." + "\n"); } - public void sayDrank(String input) { - String[] arrayString = input.split(" "); - int lastIndex = arrayString.length - 1; - int secondLastIndex = arrayString.length - 2; - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - String dateTime = arrayString[lastIndex]; - LocalDate localDate = LocalDate.parse(dateTime, formatter); - System.out.println("Date Entered: " + formatter.format(localDate) + "\n"); - String fluidDescription = arrayString[1]; - for (int i = 2; i < secondLastIndex; i++) { - fluidDescription = fluidDescription.concat(" " + arrayString[i]); + public void listFluid() { + try { + int i = 1; + for (String fluid : fluidArray) { + generateFluidParameters(fluid); + System.out.println(i + ". " + description + " of " + calories + + " calories and " + volume + " ml on " + date + " " + time + "." + "\n"); + i++; + } + System.out.println("\n"); + } catch (ArrayIndexOutOfBoundsException e) { + } - int volume = Integer.parseInt(arrayString[secondLastIndex]); - String date = arrayString[lastIndex]; - toPrint(fluidDescription, volume, date); - fluidArray.add(input); - numberOfFluids += 1; } + } diff --git a/src/main/java/seedu/duke/Keywords.java b/src/main/java/seedu/duke/Keywords.java index aa2b571ad7..63d3c6bd94 100644 --- a/src/main/java/seedu/duke/Keywords.java +++ b/src/main/java/seedu/duke/Keywords.java @@ -5,8 +5,9 @@ public class Keywords { public static final String INPUT_WORKOUT = "workout"; public static final String INPUT_WORKOUT_SCHEDULE = "schedule"; public static final String INPUT_DRINKS = "drank"; + public static final String DELETE_DRINKS = "deletefluid"; + public static final String LIST_DRINKS = "listfluids"; public static final String INPUT_ADD_WEIGHT = "addweight"; public static final String INPUT_CHECK_WEIGHT = "checkweight"; public static final String INPUT_BYE = "bye"; - } \ No newline at end of file diff --git a/src/main/java/seedu/duke/Meal.java b/src/main/java/seedu/duke/Meal.java index c1508bbc64..85112471fe 100644 --- a/src/main/java/seedu/duke/Meal.java +++ b/src/main/java/seedu/duke/Meal.java @@ -11,8 +11,8 @@ public class Meal extends Tracker{ protected int mealNumber; protected int calories; protected String description; - protected LocalDate date; - protected LocalTime time; + protected String date; + protected String time; public Meal() { this.meals = new ArrayList<>(); diff --git a/src/main/java/seedu/duke/Parser.java b/src/main/java/seedu/duke/Parser.java index 64acfbc850..042cc5996e 100644 --- a/src/main/java/seedu/duke/Parser.java +++ b/src/main/java/seedu/duke/Parser.java @@ -28,13 +28,29 @@ public static int getCalories(String inputArguments) throws DukeException { return calories; } + public static int getVolume(String inputArguments) throws DukeException { + String[] userInput = inputArguments.split(" "); + int length = userInput.length; + int volume = 0; + for (int i = 1; i < length ; i++) { + if (userInput[i].equals("/v")) { + volume = parseStringToInteger(userInput[i+1]); + break; + } + } + if (volume < 0) { + throw new DukeException("Negative volume"); + } + return volume; + } + public static String getDescription(String inputArguments) throws DukeException { String[] userInput = inputArguments.split(" /c "); String description = userInput[0]; return description; } - public static LocalDate getDate(String inputArguments) throws DukeException, DateTimeParseException { + public static String getDate(String inputArguments) throws DukeException, DateTimeParseException { String[] userInput = inputArguments.split(" "); int length = userInput.length; String date = ""; @@ -45,10 +61,11 @@ public static LocalDate getDate(String inputArguments) throws DukeException, Dat } } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - return LocalDate.parse(date, formatter); + LocalDate localDate = LocalDate.parse(date, formatter); + return formatter.format(localDate); } - public static LocalTime getTime(String inputArguments) throws DukeException, DateTimeParseException { + public static String getTime(String inputArguments) throws DukeException, DateTimeParseException { String[] userInput = inputArguments.split(" "); int length = userInput.length; String time = ""; @@ -58,8 +75,9 @@ public static LocalTime getTime(String inputArguments) throws DukeException, Dat break; } } - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mma"); - return LocalTime.parse(time, formatter); + LocalTime localTime = LocalTime.parse(time); + String properTime = localTime.format(DateTimeFormatter.ofPattern("h:mma")); + return properTime; } public static int getWeight(String inputArguments) throws DukeException { From b85474d1b86f04cfff1851f22b32ffb1836c97f0 Mon Sep 17 00:00:00 2001 From: teoziyiivy Date: Mon, 11 Oct 2021 12:52:36 +0800 Subject: [PATCH 053/398] Added Add,Delete,List to WeightTracker --- src/main/java/seedu/duke/CommandManager.java | 3 ++ .../seedu/duke/DeleteWeightException.java | 4 ++ src/main/java/seedu/duke/Keywords.java | 1 + src/main/java/seedu/duke/Parser.java | 21 +++++----- src/main/java/seedu/duke/WeightTracker.java | 41 ++++++++++++++++--- 5 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 src/main/java/seedu/duke/DeleteWeightException.java diff --git a/src/main/java/seedu/duke/CommandManager.java b/src/main/java/seedu/duke/CommandManager.java index bd3e298353..2b7bd14cd2 100644 --- a/src/main/java/seedu/duke/CommandManager.java +++ b/src/main/java/seedu/duke/CommandManager.java @@ -42,6 +42,9 @@ public void commandChecker() { } else if (command.equals(Keywords.INPUT_ADD_WEIGHT)) { weightTracker.readInput(input); + } else if (command.equals(Keywords.INPUT_DELETE_WEIGHT)) { + weightTracker.readInput(input); + } else if (command.equals(Keywords.INPUT_CHECK_WEIGHT)) { weightTracker.readInput(input); diff --git a/src/main/java/seedu/duke/DeleteWeightException.java b/src/main/java/seedu/duke/DeleteWeightException.java new file mode 100644 index 0000000000..bbd12ad115 --- /dev/null +++ b/src/main/java/seedu/duke/DeleteWeightException.java @@ -0,0 +1,4 @@ +package seedu.duke; + +public class DeleteWeightException extends Exception { +} diff --git a/src/main/java/seedu/duke/Keywords.java b/src/main/java/seedu/duke/Keywords.java index aa2b571ad7..33112a7952 100644 --- a/src/main/java/seedu/duke/Keywords.java +++ b/src/main/java/seedu/duke/Keywords.java @@ -6,6 +6,7 @@ public class Keywords { public static final String INPUT_WORKOUT_SCHEDULE = "schedule"; public static final String INPUT_DRINKS = "drank"; public static final String INPUT_ADD_WEIGHT = "addweight"; + public static final String INPUT_DELETE_WEIGHT = "deleteweight"; public static final String INPUT_CHECK_WEIGHT = "checkweight"; public static final String INPUT_BYE = "bye"; diff --git a/src/main/java/seedu/duke/Parser.java b/src/main/java/seedu/duke/Parser.java index 64acfbc850..f7e2785dc7 100644 --- a/src/main/java/seedu/duke/Parser.java +++ b/src/main/java/seedu/duke/Parser.java @@ -16,9 +16,9 @@ public static int getCalories(String inputArguments) throws DukeException { String[] userInput = inputArguments.split(" "); int length = userInput.length; int calories = 0; - for (int i = 1; i < length ; i++) { + for (int i = 1; i < length; i++) { if (userInput[i].equals("/c")) { - calories = parseStringToInteger(userInput[i+1]); + calories = parseStringToInteger(userInput[i + 1]); break; } } @@ -38,9 +38,9 @@ public static LocalDate getDate(String inputArguments) throws DukeException, Dat String[] userInput = inputArguments.split(" "); int length = userInput.length; String date = ""; - for (int i = 1; i < length ; i++) { + for (int i = 1; i < length; i++) { if (userInput[i].equals("/d")) { - date = userInput[i+1]; + date = userInput[i + 1]; break; } } @@ -52,9 +52,9 @@ public static LocalTime getTime(String inputArguments) throws DukeException, Dat String[] userInput = inputArguments.split(" "); int length = userInput.length; String time = ""; - for (int i = 1; i < length ; i++) { + for (int i = 1; i < length; i++) { if (userInput[i].equals("/t")) { - time = userInput[i+1]; + time = userInput[i + 1]; break; } } @@ -62,13 +62,14 @@ public static LocalTime getTime(String inputArguments) throws DukeException, Dat return LocalTime.parse(time, formatter); } - public static int getWeight(String inputArguments) throws DukeException { + public static String getWeight(String inputArguments) throws DukeException { String[] userInput = inputArguments.split(" /d "); - int weight = parseStringToInteger(userInput[0]); - if (weight < 0) { + String weightString = userInput[0]; + int weightInt = parseStringToInteger(userInput[0]); + if (weightInt < 0) { throw new DukeException("Negative weight"); } - return weight; + return weightString; } public static String getScheduleDescription(String inputArguments) throws DukeException { diff --git a/src/main/java/seedu/duke/WeightTracker.java b/src/main/java/seedu/duke/WeightTracker.java index 71dcee6a92..e649a43c09 100644 --- a/src/main/java/seedu/duke/WeightTracker.java +++ b/src/main/java/seedu/duke/WeightTracker.java @@ -2,7 +2,7 @@ import java.util.ArrayList; -public class WeightTracker { +public class WeightTracker extends Tracker { protected ArrayList weightsArray; protected int numberOfWeights; @@ -12,6 +12,14 @@ public WeightTracker() { this.numberOfWeights = 0; } + public String getWeight(String input) { + return input.replaceAll(" /d.+", ""); + } + + public String getDate(String input) { + return input.replaceAll(".+/d ", ""); + } + public void readInput(String input) { String[] splitLine = input.split(" ", 2); String command = splitLine[0]; @@ -24,6 +32,12 @@ public void readInput(String input) { } catch (AddWeightException e) { printAddWeightException(); } + } else if (command.equals("deleteweight")) { + try { + deleteWeight(input); + } catch (DeleteWeightException e) { + printDeleteWeightException(); + } } } @@ -36,13 +50,17 @@ public void printAddWeightException() { System.out.println("There was a problem adding your weight."); } + public void printDeleteWeightException() { + System.out.println("There was a problem deleting your weight."); + } + public void addWeight(String input) throws AddWeightException { if (!input.matches("(.*) (.*)")) { throw new AddWeightException(); } else { //extracting the weight and date - String weight = input.replaceAll(" .+", ""); - String date = input.replaceAll(".+ ", ""); + String weight = getWeight(input); + String date = getDate(input); //weights.add(new WeightTracker(weight, date)); printAddWeightResponse(weight, date); weightsArray.add(input); @@ -50,10 +68,23 @@ public void addWeight(String input) throws AddWeightException { } } + public void deleteWeight(String input) throws DeleteWeightException { + int weightIndex = Parser.parseStringToInteger(input); + if (weightIndex > numberOfWeights) { + throw new DeleteWeightException(); + } else { + String weightToRemove = weightsArray.get(weightIndex - 1); + System.out.println("Noted! CLI.ckFit has successfully deleted your weight of " + + getWeight(weightToRemove) + " on " + getDate(weightToRemove)); + weightsArray.remove(weightIndex - 1); + } + } + public void printWeight() { System.out.println("Here are your recorded weights:"); - for (String a : weightsArray) { - System.out.println(a); + for (int i = 0; i < numberOfWeights; i++) { + System.out.println(getWeight(weightsArray.get(i)) + " " + + getDate(weightsArray.get(i))); } } } From 819e0b1a80b916e32701414fb60f67330c02ce0e Mon Sep 17 00:00:00 2001 From: teoziyiivy Date: Mon, 11 Oct 2021 13:47:59 +0800 Subject: [PATCH 054/398] Added bug fixes --- .../duke/DeleteWeightIndexException.java | 4 +++ src/main/java/seedu/duke/WeightTracker.java | 26 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 src/main/java/seedu/duke/DeleteWeightIndexException.java diff --git a/src/main/java/seedu/duke/DeleteWeightIndexException.java b/src/main/java/seedu/duke/DeleteWeightIndexException.java new file mode 100644 index 0000000000..893cceb772 --- /dev/null +++ b/src/main/java/seedu/duke/DeleteWeightIndexException.java @@ -0,0 +1,4 @@ +package seedu.duke; + +public class DeleteWeightIndexException extends Exception { +} diff --git a/src/main/java/seedu/duke/WeightTracker.java b/src/main/java/seedu/duke/WeightTracker.java index e649a43c09..3576376357 100644 --- a/src/main/java/seedu/duke/WeightTracker.java +++ b/src/main/java/seedu/duke/WeightTracker.java @@ -37,6 +37,8 @@ public void readInput(String input) { deleteWeight(input); } catch (DeleteWeightException e) { printDeleteWeightException(); + } catch (DeleteWeightIndexException e) { + printDeleteWeightIndexException(); } } } @@ -47,15 +49,22 @@ public void printAddWeightResponse(String weight, String date) { } public void printAddWeightException() { - System.out.println("There was a problem adding your weight."); + System.out.println("There was a problem adding your weight.\n" + + "Please follow the format: addweight /d "); } public void printDeleteWeightException() { - System.out.println("There was a problem deleting your weight."); + System.out.println("There was a problem deleting your weight.\n" + + "Please follow the format: deleteweight "); + } + + public void printDeleteWeightIndexException() { + System.out.println("There was a problem deleting your weight.\n" + + "Please ensure the index is within the list."); } public void addWeight(String input) throws AddWeightException { - if (!input.matches("(.*) (.*)")) { + if (!input.matches("(.*) /d (.*)")) { throw new AddWeightException(); } else { //extracting the weight and date @@ -68,14 +77,17 @@ public void addWeight(String input) throws AddWeightException { } } - public void deleteWeight(String input) throws DeleteWeightException { + public void deleteWeight(String input) throws DeleteWeightException, DeleteWeightIndexException { + if (input.isEmpty() || input.matches("deleteweight")) { + throw new DeleteWeightException(); + } int weightIndex = Parser.parseStringToInteger(input); if (weightIndex > numberOfWeights) { - throw new DeleteWeightException(); + throw new DeleteWeightIndexException(); } else { String weightToRemove = weightsArray.get(weightIndex - 1); System.out.println("Noted! CLI.ckFit has successfully deleted your weight of " - + getWeight(weightToRemove) + " on " + getDate(weightToRemove)); + + getWeight(weightToRemove) + " on " + getDate(weightToRemove) + "."); weightsArray.remove(weightIndex - 1); } } @@ -83,7 +95,7 @@ public void deleteWeight(String input) throws DeleteWeightException { public void printWeight() { System.out.println("Here are your recorded weights:"); for (int i = 0; i < numberOfWeights; i++) { - System.out.println(getWeight(weightsArray.get(i)) + " " + System.out.println((i + 1) + ". " + getWeight(weightsArray.get(i)) + " on " + getDate(weightsArray.get(i))); } } From 1c8bcd2c3ffdd463f9ab45b5fc672804db6f574d Mon Sep 17 00:00:00 2001 From: teoziyiivy Date: Mon, 11 Oct 2021 14:03:16 +0800 Subject: [PATCH 055/398] Added bug fixes + Edit WeightTrackerTest --- .../java/seedu/duke/NoWeightsException.java | 4 +++ src/main/java/seedu/duke/WeightTracker.java | 30 +++++++++++++------ .../java/seedu/duke/WeightTrackerTest.java | 20 +++++++++++++ 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 src/main/java/seedu/duke/NoWeightsException.java diff --git a/src/main/java/seedu/duke/NoWeightsException.java b/src/main/java/seedu/duke/NoWeightsException.java new file mode 100644 index 0000000000..fc3a1f6b5b --- /dev/null +++ b/src/main/java/seedu/duke/NoWeightsException.java @@ -0,0 +1,4 @@ +package seedu.duke; + +public class NoWeightsException extends Exception { +} diff --git a/src/main/java/seedu/duke/WeightTracker.java b/src/main/java/seedu/duke/WeightTracker.java index 3576376357..335699ed0e 100644 --- a/src/main/java/seedu/duke/WeightTracker.java +++ b/src/main/java/seedu/duke/WeightTracker.java @@ -25,7 +25,11 @@ public void readInput(String input) { String command = splitLine[0]; input = input.replaceAll("^" + command + " ", ""); if (command.equals("checkweight")) { - printWeight(); + try { + printWeight(); + } catch (NoWeightsException e) { + printNoWeightsException(); + } } else if (command.equals("addweight")) { try { addWeight(input); @@ -49,20 +53,24 @@ public void printAddWeightResponse(String weight, String date) { } public void printAddWeightException() { - System.out.println("There was a problem adding your weight.\n" + System.out.println("CLI.ckFit encountered a problem adding your weight.\n" + "Please follow the format: addweight /d "); } public void printDeleteWeightException() { - System.out.println("There was a problem deleting your weight.\n" + System.out.println("CLI.ckFit encountered a problem deleting your weight.\n" + "Please follow the format: deleteweight "); } public void printDeleteWeightIndexException() { - System.out.println("There was a problem deleting your weight.\n" + System.out.println("CLI.ckFit encountered a problem deleting your weight.\n" + "Please ensure the index is within the list."); } + public void printNoWeightsException() { + System.out.println("CLI.ckFit has no recorded weights."); + } + public void addWeight(String input) throws AddWeightException { if (!input.matches("(.*) /d (.*)")) { throw new AddWeightException(); @@ -92,11 +100,15 @@ public void deleteWeight(String input) throws DeleteWeightException, DeleteWeigh } } - public void printWeight() { - System.out.println("Here are your recorded weights:"); - for (int i = 0; i < numberOfWeights; i++) { - System.out.println((i + 1) + ". " + getWeight(weightsArray.get(i)) + " on " - + getDate(weightsArray.get(i))); + public void printWeight() throws NoWeightsException { + if (numberOfWeights == 0) { + throw new NoWeightsException(); + } else { + System.out.println("Here are your recorded weights:"); + for (int i = 0; i < numberOfWeights; i++) { + System.out.println((i + 1) + ". " + getWeight(weightsArray.get(i)) + " on " + + getDate(weightsArray.get(i))); + } } } } diff --git a/src/test/java/seedu/duke/WeightTrackerTest.java b/src/test/java/seedu/duke/WeightTrackerTest.java index 09d80cc05f..1e8d72e83b 100644 --- a/src/test/java/seedu/duke/WeightTrackerTest.java +++ b/src/test/java/seedu/duke/WeightTrackerTest.java @@ -11,4 +11,24 @@ void addWeight() { String input = "addweight"; Assertions.assertThrows(AddWeightException.class, () -> weights.addWeight(input)); } + + @Test + void deleteWeight() { + WeightTracker weights = new WeightTracker(); + String input = "deleteweight"; + Assertions.assertThrows(DeleteWeightException.class, () -> weights.deleteWeight(input)); + } + + @Test + void deleteWeightIndex() { + WeightTracker weights = new WeightTracker(); + String input = "1"; + Assertions.assertThrows(DeleteWeightIndexException.class, () -> weights.deleteWeight(input)); + } + + @Test + void checkWeightIndex() { + WeightTracker weights = new WeightTracker(); + Assertions.assertThrows(NoWeightsException.class, weights::printWeight); + } } From de51fa7433fe509fe193fb23d322c270b6c4e504 Mon Sep 17 00:00:00 2001 From: EdwardZYWang Date: Mon, 11 Oct 2021 15:29:23 +0800 Subject: [PATCH 056/398] add UI, UserHelp class, junit for userhelp class --- .../java/seedu/duke/ClickfitMessages.java | 47 +++++++++++++++++++ src/main/java/seedu/duke/CommandManager.java | 12 +++-- src/main/java/seedu/duke/Duke.java | 29 ++++++------ src/main/java/seedu/duke/Keywords.java | 1 + src/main/java/seedu/duke/Parser.java | 5 ++ src/main/java/seedu/duke/Ui.java | 42 +++++++++++++++++ src/main/java/seedu/duke/UserHelp.java | 25 ++++++++++ src/test/java/seedu/duke/UserHelpTest.java | 15 ++++++ 8 files changed, 159 insertions(+), 17 deletions(-) create mode 100644 src/main/java/seedu/duke/ClickfitMessages.java create mode 100644 src/main/java/seedu/duke/UserHelp.java create mode 100644 src/test/java/seedu/duke/UserHelpTest.java diff --git a/src/main/java/seedu/duke/ClickfitMessages.java b/src/main/java/seedu/duke/ClickfitMessages.java new file mode 100644 index 0000000000..89a25b6347 --- /dev/null +++ b/src/main/java/seedu/duke/ClickfitMessages.java @@ -0,0 +1,47 @@ +package seedu.duke; + +public class ClickfitMessages { + + public static final String MESSAGE_A = System.lineSeparator() + "Lets get your fitness journey " + + "started! input any commands to get started! Type \"help commands\" to get started! " + + "If you want to read the UG, type in \"help UG\"!" + System.lineSeparator() + + "Lets work hard together in your fitness journey!"; + + public static final String MESSAGE_B = System.lineSeparator() + "Welcome back! Ready to mark " + + "another day of progress? As said before, type \"help commands\" " + + "if you get dizzy from all that fitness training!"; + + public static final String CREDITS = System.lineSeparator() + "Thank you for the hardwork today. " + + "CLI.ckFit wishes you a good day" + System.lineSeparator() + "Team CLI.ckFit is proudly " + + "brought to you by Jie Wen, Vishal, Pragyan, Ivy and Edward." + + System.lineSeparator() + "See you soon!"; + + public static final String MEMORY_STARTUP_PROMPT = System.lineSeparator() + "Welcome back! Would you " + + "like to load up the records of your fitness journey?" + System.lineSeparator() + + "Key in Y/N."; + + public static final String INCORRECT_INPUT = System.lineSeparator() + "CLI.ckFit has detected a " + + "wrong input, kindly check your inputs or type \"help commands\" for input examples."; + + public static final String MEMORY_STARTUP_N_INPUT = System.lineSeparator() + "Understood! CLI.ckFit " + + "wishes you all the best for the rest of the day"; + + public static final String MEMORY_STARTUP_Y_INPUT = System.lineSeparator() + "Understood! " + + "CLI.ckFit is accessing your storage..."; + + public static final String MEMORY_STARTUP_INCORRECT_INPUT = System.lineSeparator() + "CLI.ckFit " + + "has detected a wrong input, kindly type in either a \"Y\" or a \"N\"."; + + public static final String HELP_COMMANDS = + System.lineSeparator() + "ScheduleDescription:" + + System.lineSeparator() + + " /d " + + System.lineSeparator() + + System.lineSeparator() + + "All else:" + System.lineSeparator() + + " /c /d /t