-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CS2113-T14-4] DietaryBook #42
base: master
Are you sure you want to change the base?
Changes from 250 commits
a13a658
44da506
60fc25c
942beec
e563a49
7348828
917c550
9cd464d
b7ba81b
3ccd03e
5c97f79
6fea1da
0e12c98
cd4ea6d
920359e
ae409f5
9b0e2fa
88b3a5a
4e99bb8
1ebb527
8c2a702
15f3458
9d358bd
48c9fd4
d8d5210
a66165b
d291a52
6d4887b
e4da4f8
840662b
acd0a80
6e1ceaa
f549137
65019bc
6fe80a6
25673fd
66c5791
7234e20
17274eb
e6c036d
60728b8
0ad3d53
ccb2a92
dc7ebe4
c59c1a8
c8483a4
2c118e1
dffa920
afbbf0c
37462a0
32f8183
d6b7f35
62dce5a
42b5919
8724ea3
1cdce4e
f1d1c38
743ecb0
53afb25
745ddfc
c983477
061c9cd
a45623c
15f18ab
b28ede1
c1753f0
6c08533
7bfcd39
2dec832
01af9a0
cc7390f
09de15b
db46957
1c08701
465946d
4ae9b84
7378bca
f70f054
36aafbd
3787888
a7e73e4
6b90cfd
ac38fd8
6fc3120
ab173f6
5b1e1a8
2b16f06
7a46f6c
0bf41b7
66cee4c
49c8a11
f7d1d12
a508052
2863695
faba5e1
43dee1c
9902676
221662a
f2cc9e0
30b2195
03e0bee
a3aa572
3084624
e787bb9
b34cf34
0d362e4
73c080b
94958ed
2b1d4f5
d3279c8
539b522
b46c5a7
2d7028f
18e72cf
159dfbb
dd5eba7
54cbe20
022b7d4
3e0700d
58d9636
8e626aa
edc6f03
a698e60
b2a21e8
95c6471
3dd4740
ff288ae
ee8d466
bb91199
9fcdda3
5376ca3
dd44a64
9485a2c
43ec8ce
a3f9992
e831f8f
49529b5
0dd2a80
30ca0ff
c472680
33c335f
518101e
be5ae29
9a91757
e579218
9ce73db
5f27da9
b73c61e
3fa460e
e89793f
4421ccd
3792450
a71c91f
a77bcdd
9d2c93c
c3f99b3
b6d8e95
d47e868
f021e0d
be3b213
da8afaf
2af801f
b74db1a
27fbc63
251c0de
9375397
a0d6cc4
9305e77
001a2e9
ee18b71
f64c7b9
f5431a5
cfe39f2
3a0d247
29d1cd3
06dd83d
3c4fa91
374ac75
6f21a7c
ef7592e
a3bc36f
7bcc22f
9670687
0eac807
cb3c081
0ba2ab7
6f01334
563c8fd
7e2b8f4
7a4b10f
f89e787
e746402
5c97c67
6e43da8
11db296
15ca4ff
f89ac48
98e216e
76e1093
7685f86
c0fde24
3ab6d20
06e5885
46758f0
7bfeaf1
2522dc3
d607ea6
f7b5cdf
02bb8c3
101613f
b635f43
90a8064
68a0a0b
0114ac8
0f9940e
1c37651
539361a
85d1b4c
9da3a15
b46523c
de7035a
0faea49
bdf9f08
329892e
0082df4
55569d1
4c19930
88b43b4
70a2822
61ba0d6
fec1427
edb667a
17c777a
54a25b6
2680efb
579c29a
d3d6e1c
9a44221
236a502
4813353
6920dd9
94229ce
be6b257
54eab90
db3523d
7a8dcd3
538ddb3
15483f1
d9ef411
747d19b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: seedu.duke.DietBook | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@startuml | ||
object Saver | ||
object Loader | ||
object FoodSaveLoadManager | ||
object PersonSaveLoadManager | ||
object Command | ||
object File | ||
|
||
File <-up-> Saver | ||
File <-up-> Loader | ||
|
||
Saver <-up-> FoodSaveLoadManager | ||
Saver <-up-> PersonSaveLoadManager | ||
Loader <-up-> FoodSaveLoadManager | ||
Loader <-up-> PersonSaveLoadManager | ||
|
||
FoodSaveLoadManager <-up-> Command | ||
PersonSaveLoadManager <-up-> Command | ||
@enduml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@startuml | ||
|
||
-> FoodSaveLoadManager : load() | ||
activate FoodSaveLoadManager | ||
|
||
FoodSaveLoadManager -> Loader : static load() | ||
|
||
activate Loader | ||
Loader -> FileLoader : load() | ||
|
||
activate FileLoader | ||
loop all lines | ||
activate Scanner | ||
FileLoader -> Scanner : readline() | ||
Scanner --> FileLoader : line data | ||
destroy Scanner | ||
end | ||
FileLoader --> Loader : FileLoader | ||
deactivate FileLoader | ||
|
||
Loader --> FoodSaveLoadManager : FileLoader | ||
deactivate Loader | ||
deactivate FoodSaveLoadManager | ||
@enduml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@startuml | ||
-> FoodSaveLoadManager : save | ||
activate FoodSaveLoadManager | ||
|
||
|
||
loop all food items | ||
loop every entry in a food object | ||
activate Saver | ||
FoodSaveLoadManager -> Saver : add() | ||
end | ||
end | ||
|
||
FoodSaveLoadManager -> Saver : save() | ||
deactivate Saver | ||
|
||
activate FileWriter | ||
loop all entries in Saver table | ||
Saver -> FileWriter : write() | ||
end | ||
destroy FileWriter | ||
|
||
deactivate FoodSaveLoadManager | ||
|
||
@enduml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
@startuml | ||
-> FoodSaveLoadManager : save | ||
|
||
loop all food items | ||
loop every entry in a food object | ||
FoodSaveLoadManager -> Saver : add() | ||
end | ||
end | ||
|
||
FoodSaveLoadManager -> Saver : save() | ||
loop all entries in Saver table | ||
Saver -> FileWriter : write() | ||
end | ||
@enduml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# About us | ||
we are an idiosyncratic and narcissistic batch of self-righteous | ||
elitist who defends presumably morally questionable positions. | ||
Also we are cheap! | ||
|
||
|
||
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) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Heng Fu Yuen | [Github](https://github.com/HengFuYuen) | [Portfolio](docs/team/johndoe.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,155 @@ | ||
# Developer Guide | ||
|
||
## Design & implementation | ||
* Table of Contents | ||
{:toc} | ||
|
||
## Design | ||
|
||
### UI component | ||
![Ui component](diagrams/Ui component.png) | ||
|
||
**API**: [`Ui.java`](https://github.com/AY2021S1-CS2113-T14-4/tp/blob/master/src/main/java/seedu/dietbook/Ui.java) | ||
|
||
The `UI` component, | ||
* Takes in user command and passes to the `Logic` components for command execution. | ||
* Updates the user about any changes in the data after executing the command or errors encountered when executing the commands. | ||
|
||
The UI has a dependency with two enumeration class, [`ActivityLevel`](https://github.com/AY2021S1-CS2113-T14-4/tp/blob/master/src/main/java/seedu/dietbook/person/ActivityLevel.java) and [`Gender`](https://github.com/AY2021S1-CS2113-T14-4/tp/blob/master/src/main/java/seedu/dietbook/person/Gender.java) as descriptions of each [`ActivityLevel`](https://github.com/AY2021S1-CS2113-T14-4/tp/blob/master/src/main/java/seedu/dietbook/person/ActivityLevel.java) and [`Gender`](https://github.com/AY2021S1-CS2113-T14-4/tp/blob/master/src/main/java/seedu/dietbook/person/Gender.java) is required. Increased coupling was sacrificed to reduce code duplicates and increase ease of code extension/editing. | ||
|
||
## Implementation | ||
{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps you should delete this line for the final version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted! Thank you! |
||
|
||
### [Proposed] Enter user information feature | ||
|
||
#### Proposed Implementation | ||
The proposed feature utilised two commands words [`name`](UserGuide.md/####Entering username: `name`) and [`info`](UserGuide.md/####Entering user information: `info`) that allows users to enter their name using the [`name`](UserGuide.md/####Entering username: `name`) command and [`info`](UserGuide.md/####Entering user information: `info`) to enter other information, such as age, gender, height, activity level, original, current and target weight, separately. | ||
|
||
The proposed feature to enter user information is facilitated by `Manager` which stores a [`Person`](https://github.com/AY2021S1-CS2113-T14-4/tp/blob/master/src/main/java/seedu/dietbook/person/Person.java) which | ||
stores all user information provided. It implements the following operation: | ||
|
||
* Manager#setPerson(String newName, Gender newGender, int newAge, int newHeight, int newOriginalWeight, int newCurrentWeight, int newTargetWeight, ActivityLevel newActivityLevel) - Calls the method below to set the attribute values of the `Person` object. | ||
* Person#setAll(String newName, Gender newGender, int newAge, int newHeight, int newOriginalWeight, int newCurrentWeight, int newTargetWeight, ActivityLevel newActivityLevel) - Updates the attribute values of the `Person` object. | ||
|
||
Both operation are only executed by the `Manager` class of the `Logic` component. Only one instance of `Person` is ever instantiated. A default person is instantiated at the start with default attribute values and when the user enters their information for the first time during the set up, all the default values would be updated to the inputted values. Therefore, the command to enter the user information will result in a change in the attribute values and not the creation of a new `Person` object. | ||
|
||
Given below is the example usage scenario and how the feature works. | ||
|
||
Step 1. When the user launches the application for the first time. A default `Person` object will be initialised by `Manager` and the user will be prompted to enter their name. | ||
|
||
![Enter Info Step1](diagrams/Enter Info Step1.png) | ||
|
||
Step 2. The user executes `name Jack` command to enter their name into DietBook. The `name` command calls `Manager#setName(Jack)`, to store the name in `Manager` first. After which, user will be prompted to enter all other details. | ||
|
||
![Enter Info Step2](diagrams/Enter Info Step2.png) | ||
|
||
Step 3. The user executes a command like the following `info g/M a/21 h/175 o/85 c/85 t/75 l/2` to enter all other personal information including age, gender, height, activity level, original, current and target weight. The `info` command then calls `Parse#executeProcessedInfo(info g/M a/21 h/175 o/85 c/85 t/75 l/2, manager)` which would parse the user command, check input validity by using methods in `InputChecker` and calls `Manager#setPerson(Jack, Gender.MALE, 21, 175, 85, 85, 75, ActivityLevel.LOW)` which proceeds to call `Person#setAll(Jack, Gender.MALE, 21, 175, 85, 85, 75, ActivityLevel.LOW)`. | ||
|
||
![Enter Info Step3](diagrams/Enter Info Step3.png) | ||
|
||
The following sequence diagrams shows how the feature works. | ||
|
||
`name` command | ||
|
||
![Name sequence diagram](diagrams/Name sequence diagram.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the constructor block is wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted! Thanks for spotting the error! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps you should align the dotted line to the middle of the execute() block. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted! Thanks for spotting the error! |
||
|
||
`info` command | ||
|
||
![Info sequence diagram](diagrams/Info sequence diagram.png) | ||
|
||
#### Design considerations: | ||
|
||
Aspect: Whether to enter name and other information separately or together | ||
|
||
* **Alternative 1 (current choice)**: Enter name and other information separately | ||
* Pros: Increase user interaction and engagement. | ||
* Cons: Enter information using two commands. | ||
|
||
* **Alternative 2**: Enter name and other information together | ||
* Pros: Enter all information at once. | ||
* Cons: Increase user interaction and engagement. | ||
|
||
Aspect: Whether to use singleton pattern for Person class | ||
|
||
* **Alternative 1 (current choice)**: Did not use singleton pattern for `Person` | ||
* Pros: Reduce coupling and increase testability. | ||
* Cons: Risk of creating multiple `Person` object by mistake and there might be negative consequence in creating multiple objects. | ||
|
||
However, there is minimal risk of creating multiple `Person` object by mistake and minimal negative consequence in creating multiple objects as long as the `Manager` refers the correct instance of `Person`. | ||
|
||
* **Alternative 2**: Use singleton pattern for `Person` | ||
* Pros: Easy to implement, prevent the instantiation of more than one `Person` object. | ||
* Cons: Increase coupling and reduce testability | ||
|
||
Aspect: Changing attribute values in `Person` object or creating new `Person` object | ||
|
||
* **Alternative 1 (current choice)**: Changing attribute values in `Person` object | ||
* Pros: Reduce the number of objects being created to reduce memory usage and reduce the risk of creating multiple objects which can potentially lead to negative consequences and bugs. | ||
* Cons: Unable to write tests as method chains. | ||
|
||
* **Alternative 2**: Creating new `Person` object | ||
* Pros: Ability to write tests as method chains. | ||
* Cons: Creation of many objects, which take up memory spaces and ensure that only the correct `Person` instance is kept and referred to. | ||
|
||
## Save/Load Feature | ||
|
||
The Save/Load feature is implemented by the saveload package. | ||
At the base of the package, there is the <mark> Saver </mark> | ||
and <mark> Loader </mark> class. | ||
|
||
### Architecture | ||
![Alt text](save_load_feature/Architecture.png) | ||
Note only the Saver and Loader class is flexible. They can be adapted to new situations without modifying | ||
the code. The FoodSaveLoadManager and PersonSaveLoadManager are written specifically for this version. They | ||
will have to be modified/replaced for future versions. | ||
|
||
#### Saver class | ||
|
||
Stores data in a internal table with length and height specified. | ||
Handles the storage of its data by writing to a text file. | ||
|
||
##### Constructor | ||
Specifies the length and height of the internal Saver table | ||
##### Main Methods | ||
* Saver#save() saves the current data to the file in the folder with the given file name | ||
* Saver#add() Store String data in the x,y position in the table | ||
|
||
#### Loader class | ||
Loads data from a text file and stores it in a internal table just like the saver | ||
##### Constructor | ||
static method Loader.load(folder name , file name) : creates a Loader object with | ||
a table storing the data found in the text file | ||
##### Main Methods | ||
* Loader#get() retrives the data stored in the loader | ||
|
||
#### FoodSaveLoadManager class | ||
Built on top of Saver and Loader class to implement save/load functionality | ||
for list of food items the user has input into the dietbook. Contains a instance | ||
of both <mark> Saver </mark> and <mark> Loader </mark>. It has its own folder to work with, | ||
the user only has to specify the file name. | ||
##### Main Methods | ||
* FoodSaveLoadManager#save() saves the list of food objects to the specified file name | ||
* FoodSaveLoadManager#load() loads the file and returns the list of food objects stored inside it | ||
|
||
#### PersonSaveLoadManager class | ||
Built on top of Saver and Loader class to implement save/load functionality for user information | ||
Same as FoodSaveLoadManager, it has its own folder to work with, the user only has to specify the file name | ||
Unlike the FoodSaveLoadManager, it stores the data inside itself and can be updated. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps a class and sequence diagram would help convey the idea better idea. |
||
##### Main Methods | ||
* PersonSaveLoadManager#save() save the current state into the file | ||
* PersonSaveLoadManager#load() loads the file | ||
* Setters and Getters for all the personal data in this current version | ||
|
||
#### UML diaghram | ||
##### FoodSaveLoadManager#save() | ||
![Alt text](save_load_feature/FoodSaveLoadManager_save.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps you should end the dotted line at the cross There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
##### FoodSaveLoadManager#load() | ||
![Alt text](save_load_feature/FoodSaveLoadManager_load.png) | ||
similiar diaghrams for PersonSaveLoadManager | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
## Product scope | ||
### Target user profile | ||
|
||
{Describe the target user profile} | ||
NUS students living on campus who would like to track their daily food and nutritional intake. | ||
|
||
### Value proposition | ||
|
||
|
@@ -23,12 +164,11 @@ | |
|
||
## Non-Functional Requirements | ||
|
||
{Give non-functional requirements} | ||
1. Should work on any mainstream OS as long as `Java 11` is installed in the system. | ||
|
||
## Glossary | ||
|
||
* *glossary item* - Definition | ||
* *Mainstream OD* - Windows, Linux, Unix, OS-X | ||
* *Food items* - Includes both food and drinks | ||
|
||
## Instructions for manual testing | ||
|
||
{Give instructions on how to do a manual product testing e.g., how to load sample data to be used for testing} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
# Duke | ||
# DietBook | ||
|
||
{Give product intro here} | ||
[![CI status](https://github.com/AY2021S1-CS2113-T14-4/tp/workflows/Java%20CI/badge.svg)](https://github.com/AY2021S1-CS2113-T14-4/tp/actions) | ||
|
||
DietBook is a Command Line Interface (CLI) desktop application designed to **track your food and nutritional intake** as well as provide you with your **daily calorie recommendation**. As the application mainly targets _NUS students staying on campus_, it has a **database prepopulated with food items commonly found around NUS**. This allows for such food items to be easily added to the list of food items consumed for tracking. | ||
|
||
**Useful links:** | ||
|
||
* If you would like to use DietBook, head over to [User Guide](UserGuide.md) to get started. | ||
* If you would like to know more about developing DietBook, head over to [Developer Guide](DeveloperGuide.md). | ||
* If you would like to know more about the developers, head over to [About Us](AboutUs.md). | ||
|
||
**Acknowledgements:** | ||
|
||
* Libraries used: [JUnit5](https://github.com/junit-team/junit5) | ||
|
||
Useful links: | ||
* [User Guide](UserGuide.md) | ||
* [Developer Guide](DeveloperGuide.md) | ||
* [About Us](AboutUs.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the arrow pointing to enumeration be dotted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing! Yes, Ui has dependencies and not associations with the enum classes which is why I used the dashed lines. Perhaps my following explanations were not clear enough. Thanks for the feedback!