Skip to content

Commit

Permalink
Merge pull request #72 from 24Donovan24/branch-furtherSetsRegexChanges
Browse files Browse the repository at this point in the history
Modify Regex for Sets
  • Loading branch information
kavantan authored Oct 13, 2022
2 parents 4a8ff12 + d8b9641 commit 1225055
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
19 changes: 10 additions & 9 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Format: `:help`

Adds an exercise that we have done for the day.

Format: `:a <exercise name> <weight(kg)> <sets> <reps>`
Format: `:a n/<exercise name> w/<weight(kg)> s/<sets> r/<reps>`

##### Parameter constraints:
* The weight **must be a positive decimal number**
Expand Down Expand Up @@ -103,17 +103,18 @@ Format: `:wq`

## Command Summary

| Action | Format | Examples |
|---------------------|------------------------------------------|-----------------|
| **Add exercise** | :a <exercise> <weight(kg)> <sets> <reps> | :a squat 60 5 5 |
| **Delete exercise** | :d <index> | :d 3 |
| **List exercises** | :ls | :ls |
| **Help menu** | :help | :help |
| **Exit program** | :wq | :wq |
| Action | Format | Examples |
|---------------------|--------------------------------------------------|-------------------------|
| **Add exercise** | :a n/<exercise> w/<weight(kg)> s/<sets> r/<reps> | :a n/Squat w/60 s/5 r/5 |
| **Delete exercise** | :d <index> | :d 3 |
| **List exercises** | :ls | :ls |
| **Help menu** | :help | :help |
| **Exit program** | :wq | :wq |

--------------------------------------------------------------------------------------------------------------------

## Glossary of Terminologies
* **Exercise** : Activity requiring physical effort, carried out to sustain or improve health and fitness
* **Exercise** : Physical activity done in a regular gym that is structured and repetitive, usually involving
some weights.
* **Reps** : Number of times you perform a specific exercise
* **Sets** : Number of cycles of reps that you complete
5 changes: 3 additions & 2 deletions src/main/java/gim/model/exercise/Sets.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
*/
public class Sets {

public static final String MESSAGE_CONSTRAINTS = "Sets can only take non negative integer values";
public static final String VALIDATION_REGEX = "^[0-9]\\d*$";
public static final String MESSAGE_CONSTRAINTS = "Sets can only take positive integer values, up to 3 digits";
public static final String VALIDATION_REGEX = "^(?:([1-9])|([1-9][0-9])|([1-9][0-9][0-9]))$";


public final String value;

Expand Down
5 changes: 5 additions & 0 deletions src/test/java/gim/model/exercise/SetsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public void isValidSets() {
assertFalse(Sets.isValidSets(" ")); // spaces only
assertFalse(Sets.isValidSets("abc")); // not an integer
assertFalse(Sets.isValidSets("-1")); // negative integer
assertFalse(Sets.isValidSets("0")); // zero
assertFalse(Sets.isValidSets("3.5")); // positive decimal
assertFalse(Sets.isValidSets("-1.5")); // negative decimal
assertFalse(Sets.isValidSets("01")); // leading zeros
assertFalse(Sets.isValidSets("10000")); // positive integer above 3 digits

// valid sets
assertTrue(Sets.isValidSets("3")); // single digit
Expand Down

0 comments on commit 1225055

Please sign in to comment.