-
Notifications
You must be signed in to change notification settings - Fork 89
[CS2113-F11-1] FITNUS #27
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
base: master
Are you sure you want to change the base?
Changes from 101 commits
5106842
c0899a9
45ba6ff
2b1ec01
223a438
8f246d9
945441b
46d39d9
43b922f
066cdd2
540e4c1
8f99327
3c1a313
d127d10
cf3dc54
2c24bdd
15f9e6c
29e56e7
2a84d82
a0bdfd1
c3c2e90
9a4efd0
275d778
caea4fd
92e4bc3
fca8b8d
2c759a9
662d141
21e424a
4daa67b
31f14f8
76140cf
2f91d2f
6056f8b
c9d8ac5
90e81d7
6b19e90
6f95551
664d4e0
264bf1b
74fa347
3383f86
b0df278
dc239a8
d658f3f
4a0781e
003d1b1
ee55f79
6d21513
02fbc12
0e9c3c8
08bd893
0915bdc
4d860ff
65d1a5d
0b6eb8c
5f1d1ce
a847a3d
c3fd3a3
6204a80
3a01fbd
19d6c1a
9ad6efa
6e73839
3f4a38d
43758c6
fd0cc7d
ae4184c
10865ac
6d212b8
f1cd21a
f228f50
81d8045
3a733a2
791812f
dcb4374
8e8861f
568ea6f
7b542b6
d77e127
ace0288
22f9aba
9e2048e
4854a86
92e2d4e
a666a62
ccc9a90
d945506
d3ecf35
d251389
cea9d79
3b75cd6
f9e1a8b
398794d
c8c2562
59c07d4
8e0ce34
7ff361c
5c36530
a95800d
ebdbc39
fa2837f
08d105c
cb47052
c72765b
6ca3648
a1640f3
ae819b3
e6b83c0
6990891
5971c54
1a541bf
13553d7
d3879a6
8911f32
5374a8c
41ef618
493a621
8fec492
f0c41ae
f136a4a
dbe4c83
b493a99
2ee5806
1752378
a773093
ead7772
970e22b
31efa75
583de53
6b0a13e
a428600
dcfb206
2d8faaa
df80e92
cc0fff1
d921be9
b4a5479
0192df9
c54de2d
c00c0c6
37a9f61
9b4a10e
64b2a2a
ecb012d
1dc8963
c817f41
5193f21
7673bc8
75395ef
ed9ce44
49b1549
db529b9
ed8d15c
43cfd28
4ed88a3
fff0055
5baed11
632a82b
f181617
b63c94a
15c64cd
5d8345e
922981d
007bc02
25c5ce4
2286b58
6b9dbc6
a95ed63
b7515da
c7b817c
8ef7eee
52db76c
5133f60
07875cb
24f568d
39ccf2f
80a6ac8
8a8e8c2
71821d8
561c41d
5113d15
592656a
d5f28a3
f911de5
7e6e5c8
647881b
679ebd0
738c947
0a3c513
fd754e2
fb7205f
e97fd48
717295c
ac40ab8
4fcc5df
34bbb4e
28cb8d4
c8401cf
1bfbd1a
6638b6f
bd7f8a7
72a88df
ea7f8d3
815bf5f
d3e8ce6
20aee5d
9503ff2
0031283
deee6b7
0936716
8234aea
999f916
85c86ab
5c276b3
1184a29
ce334db
7f4f941
7213833
5235a0a
dc88434
a59ae1b
6d5145b
5aac026
5847537
aa02ae5
b5f5bb1
8cd19f7
d21417d
3a6ab4f
77e3033
7a96072
46d39f9
658c3c2
f832042
a6d662b
b9a29ef
51f7669
13cfffb
d31d8a8
8351894
697d21d
471aa4d
69570af
b11d188
d2fc745
e0f2c85
3c0f01a
85244db
68c97c1
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 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ checkstyle { | |
|
||
run{ | ||
standardInput = System.in | ||
enableAssertions = true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# About us | ||
|
||
Display | Name | Github Profile | Portfolio | ||
--------|:----:|:--------------:|:---------: | ||
 | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
 | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
 | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
 | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
 | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
Display | Name | Github Profile | Portfolio | ||
--------|:-----------:|:--------------------------------------:|:---------: | ||
 | Kevin Zhang | [Github](https://github.com/kevinz420) | [Portfolio](docs/team/johndoe.md) | ||
 | Ethan Huang | [Github](https://github.com/remy9926) | [Portfolio](docs/team/johndoe.md) | ||
 | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
 | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
 | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,8 +6,37 @@ | |||||||||||||||||||||
|
||||||||||||||||||||||
## Design & implementation | ||||||||||||||||||||||
|
||||||||||||||||||||||
{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.} | ||||||||||||||||||||||
### Handling User Inputs & Displaying Output | ||||||||||||||||||||||
|
||||||||||||||||||||||
A lot of the initial project setup that deals with things like parsing, displaying outputs back to the user, exceptions, etc. are strongly inspired by the address book example project demoed in class. Specifically, we have classes that are responsible for various aspects of our project in order to follow the single-responsibility principle and limit the amount of coupling. | ||||||||||||||||||||||
|
||||||||||||||||||||||
One specific design implementation we chose was having a Command superclass that all commands in our application will inherit from. This allows every command we write in the future to be guaranteed to possess all methods specified in the superclass. Therefore we can call these methods in our main function without needing to worry about the differences between various commands because they all inherit from the same parent. Another alternative we considered was simply making each separate command its own function and calling them from our parser class. However, we want to keep the commands as high level as possible and avoid calling more lower-level functions if possible so we can provide more encapsulation to each command. Therefore, we decided to go with this class-based command hierarchy that was also found in the example address book repo. | ||||||||||||||||||||||
|
||||||||||||||||||||||
Below is a class diagram that describes how our various components interact with one another: | ||||||||||||||||||||||
|
||||||||||||||||||||||
 | ||||||||||||||||||||||
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. 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. Good use of '+' and '-' for the class diagram. 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. 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. |
||||||||||||||||||||||
|
||||||||||||||||||||||
The parser class is responsible for reading the user input and creating specific command objects. All of these subcommands inherit from a general Command parent class which has an `execute` method that can be called regardless of child class and will return a CommandResult object. The CommandResult object dictates what info (string or list of items) needs to be returned to the user for viewing. Both CommandResult and TextUi (responsible for actually displaying data from CommandResult to user) will only print objects from classes that inherit from the Printable interface. This ensures that objects in the `relevantItems` list are all serializable as a human-readable string to be displayed to the end user. | ||||||||||||||||||||||
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.
Suggested change
Maybe enclose the class/interface names in code-blocks? |
||||||||||||||||||||||
|
||||||||||||||||||||||
### Update Exercises from Log feature | ||||||||||||||||||||||
|
||||||||||||||||||||||
The proposed feature is to allow users to update exercises from the ExerciseLog class to allow for full CRUD functionality of the class. Currently, users are able to create exercises and log them as well as view all the exercises that they have created, but in the case of a typo, they are unable to update the log to accomodate for the user error. To improve the user experience, this update feature has been proposed to allow users to have a better experience using the app. | ||||||||||||||||||||||
|
||||||||||||||||||||||
The update feature will be implemented by allowing users to select the task that they want to edit by specifying the month and day that they logged this exercise at, as well as the corresponding exercise name and the number of calories that the exercise has burned. This is because each exercise is stored within Day objects, and in order to check if two exercises are equivalent, we check both the exerciseName and caloriesBurned fields. Thus, these parameters will need to be specified by the user in order to update the exercise log. | ||||||||||||||||||||||
|
||||||||||||||||||||||
Below is an example of how this feature will work: | ||||||||||||||||||||||
|
||||||||||||||||||||||
Step 1: Upon starting the app, the ExerciseLog class is initialized and a log is created for the user to log their exercises. | ||||||||||||||||||||||
|
||||||||||||||||||||||
<img width="661" alt="Screenshot 2023-10-22 at 22 21 04" src="https://github.com/Remy9926/tp/assets/95456114/933b3636-eba7-442b-bcf2-aec22ef49dba"> | ||||||||||||||||||||||
|
||||||||||||||||||||||
Step 2: The user calls the log command with the specified parameters to add a new exercise to the list. However, the user notices that they made a typo and want to change the details of the exercise that they just logged. | ||||||||||||||||||||||
Comment on lines
+36
to
+40
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.
Suggested change
Maybe indent and bold the steps section to make it create a hierarchy of sections. |
||||||||||||||||||||||
|
||||||||||||||||||||||
<img width="682" alt="Screenshot 2023-10-22 at 22 23 59" src="https://github.com/Remy9926/tp/assets/95456114/318cd321-6516-4163-a4ce-4a9e5d5edf7b"> | ||||||||||||||||||||||
|
||||||||||||||||||||||
Step 3: The user calls the update command with the information of the old exercise as well as the new information that the user wants to update with. With this, the update is done. | ||||||||||||||||||||||
|
||||||||||||||||||||||
<img width="652" alt="Screenshot 2023-10-22 at 22 25 09" src="https://github.com/Remy9926/tp/assets/95456114/d07d5570-11fc-426c-877d-feb31a338f0a"> | ||||||||||||||||||||||
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. maybe add a class diagram for the log class 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. add a sequence diagram for creating a new log |
||||||||||||||||||||||
|
||||||||||||||||||||||
## Product scope | ||||||||||||||||||||||
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. unfinished DG |
||||||||||||||||||||||
### Target user profile | ||||||||||||||||||||||
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. Target user profile, Value proposition, User Stories, and Non-Functional Requirements is not updated. |
||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ Useful links: | |
* [User Guide](UserGuide.md) | ||
* [Developer Guide](DeveloperGuide.md) | ||
* [About Us](AboutUs.md) | ||
|
||
test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,115 @@ | ||
package seedu.duke; | ||
|
||
import java.util.Scanner; | ||
import seedu.duke.commands.Command; | ||
import seedu.duke.commands.CommandResult; | ||
import seedu.duke.commands.ExitCommand; | ||
import seedu.duke.commands.meal.MealCommand; | ||
import seedu.duke.data.GoalList; | ||
import seedu.duke.data.meal.Meal; | ||
import seedu.duke.parser.Parser; | ||
import seedu.duke.exerciselog.Log; | ||
import seedu.duke.ui.TextUi; | ||
import java.util.ArrayList; | ||
|
||
/** | ||
* Entry point of the Address Book application. | ||
* Initializes the application and starts the interaction with the user. | ||
*/ | ||
public class Duke { | ||
|
||
/** | ||
* Version info of the program. | ||
*/ | ||
public static final String VERSION = "AddressBook Level 2 - Version 1.0"; | ||
public static GoalList goals = new GoalList(); | ||
public static Log exerciseLog = new Log(); | ||
static ArrayList<Meal> meals = new ArrayList<Meal>(); | ||
private TextUi ui; | ||
|
||
// private StorageFile storage; | ||
public static void main(String... launchArgs) { | ||
new Duke().run(launchArgs); | ||
} | ||
|
||
/** | ||
* @param launchArgs | ||
* Runs the program until termination. | ||
*/ | ||
public void run(String[] launchArgs) { | ||
start(launchArgs); | ||
runCommandLoopUntilExitCommand(); | ||
exit(); | ||
} | ||
|
||
/** | ||
* Sets up the required objects, loads up the data from the storage file, and | ||
* prints the welcome message. | ||
* | ||
* @param launchArgs arguments supplied by the user at program launch | ||
*/ | ||
private void start(String[] launchArgs) { | ||
try { | ||
this.ui = new TextUi(); | ||
// this.storage = initializeStorage(launchArgs); | ||
ui.showWelcomeMessage(VERSION, "storage.getPath()"); | ||
MealCommand.setMeals(meals); | ||
} catch (Exception e) { // TODO: change to specific storage exceptions later | ||
ui.showInitFailedMessage(); | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Prints the Goodbye message and exits. | ||
*/ | ||
private void exit() { | ||
ui.showGoodbyeMessage(); | ||
System.exit(0); | ||
} | ||
|
||
/** | ||
* Main entry-point for the java.duke.Duke application. | ||
* Reads the user command and executes it, until the user issues the exit | ||
* command. | ||
*/ | ||
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?"); | ||
|
||
Scanner in = new Scanner(System.in); | ||
System.out.println("Hello " + in.nextLine()); | ||
private void runCommandLoopUntilExitCommand() { | ||
Command command; | ||
do { | ||
String userCommandText = ui.getUserCommand(); | ||
command = new Parser().parseCommand(userCommandText); | ||
CommandResult result = executeCommand(command); | ||
ui.showResultToUser(result); | ||
|
||
} while (!ExitCommand.isExit(command)); | ||
} | ||
|
||
/** | ||
* Executes the command and returns the result. | ||
* | ||
* @param command user command | ||
* @return result of the command | ||
*/ | ||
private CommandResult executeCommand(Command command) { | ||
try { | ||
CommandResult result = command.execute(); | ||
// storage.save(addressBook); | ||
return result; | ||
} catch (Exception e) { | ||
ui.showToUser(e.getMessage()); | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
// /** | ||
// * Creates the StorageFile object based on the user specified path (if any) or | ||
// the default storage path. | ||
// * @param launchArgs arguments supplied by the user at program launch | ||
// * @throws InvalidStorageFilePathException if the target file path is | ||
// incorrect. | ||
// */ | ||
// private StorageFile initializeStorage(String[] launchArgs) throws | ||
// InvalidStorageFilePathException { | ||
// boolean isStorageFileSpecifiedByUser = launchArgs.length > 0; | ||
// return isStorageFileSpecifiedByUser ? new StorageFile(launchArgs[0]) : new | ||
// StorageFile(); | ||
// } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package seedu.duke.commands; | ||
|
||
/** | ||
* Represents an executable command. | ||
*/ | ||
public class Command { | ||
String userCommand; | ||
|
||
public Command() { | ||
} | ||
|
||
public Command(String cmd){ | ||
this.userCommand = cmd; | ||
} | ||
|
||
public CommandResult execute() throws Exception { | ||
throw new UnsupportedOperationException("This method is to be implemented by child classes"); | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package seedu.duke.commands; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import seedu.duke.data.Printable; | ||
|
||
/** | ||
* Represents the result of a command execution. | ||
*/ | ||
public class CommandResult { | ||
|
||
/** | ||
* The feedback message to be shown to the user. Contains a description of the execution result | ||
*/ | ||
public final String feedbackToUser; | ||
|
||
/** | ||
* The list of objects that was produced by the command | ||
*/ | ||
private final List<? extends Printable> relevantItems; | ||
|
||
public CommandResult(String feedbackToUser) { | ||
this.feedbackToUser = feedbackToUser; | ||
relevantItems = null; | ||
} | ||
|
||
public CommandResult(String feedbackToUser, List<? extends Printable> relevantItems) { | ||
this.feedbackToUser = feedbackToUser; | ||
this.relevantItems = relevantItems; | ||
} | ||
|
||
/** | ||
* Returns a list of objects relevant to the command result, if any. | ||
* @return relevant items | ||
*/ | ||
public Optional<List<? extends Printable>> getRelevantItems() { | ||
return Optional.ofNullable(relevantItems); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package seedu.duke.commands; | ||
|
||
/** | ||
* Terminates the program. | ||
*/ | ||
public class ExitCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "exit"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Exits the program.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
public static final String MESSAGE_EXIT_ACKNOWEDGEMENT = "Exiting FITNUS as requested ..."; | ||
|
||
@Override | ||
public CommandResult execute() { | ||
return new CommandResult(MESSAGE_EXIT_ACKNOWEDGEMENT); | ||
} | ||
|
||
public static boolean isExit(Command command) { | ||
return command instanceof ExitCommand; // instanceof returns false if it is null | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package seedu.duke.commands; | ||
|
||
import seedu.duke.Duke; | ||
import seedu.duke.ui.TextUi; | ||
import seedu.duke.data.exception.IncorrectFormatException; | ||
|
||
|
||
public class GoalCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "set"; | ||
|
||
public GoalCommand(String cmd){ | ||
super(cmd); | ||
} | ||
|
||
public CommandResult execute() { | ||
try{ | ||
Duke.goals.addGoal(this.userCommand); | ||
String addGoalResultMsg = TextUi.addGoalSuccessMessage(Duke.goals); | ||
return new CommandResult(addGoalResultMsg); | ||
|
||
}catch(IncorrectFormatException ife){ | ||
ife.handleException(); | ||
}catch(NumberFormatException nfe){ | ||
System.out.println("Please input a valid number for calories."); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package seedu.duke.commands; | ||
|
||
|
||
/** | ||
* Shows help instructions. | ||
*/ | ||
public class HelpCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "help"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows program usage instructions.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
|
||
@Override | ||
public CommandResult execute() { | ||
return new CommandResult( | ||
HelpCommand.MESSAGE_USAGE | ||
// + "\n" + DeleteCommand.MESSAGE_USAGE | ||
// + "\n" + ClearCommand.MESSAGE_USAGE | ||
// + "\n" + FindCommand.MESSAGE_USAGE | ||
// + "\n" + ListCommand.MESSAGE_USAGE | ||
// + "\n" + ViewCommand.MESSAGE_USAGE | ||
// + "\n" + ViewAllCommand.MESSAGE_USAGE | ||
); | ||
} | ||
} |
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.
In the class diagram, maybe use same font size for the text of same type?