-
-
Notifications
You must be signed in to change notification settings - Fork 735
Add split-second-stopwatch exercise #2968 #2977
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
Add split-second-stopwatch exercise #2968 #2977
Conversation
Add split-second-stopwatch exercise Implement the split-second-stopwatch practice exercise with: - State management (ready/running/stopped) - Time tracking for current lap and total elapsed time - Lap functionality with previous laps history - Start, stop, reset operations with proper state validation - Error handling for invalid state transitions - Time formatting in HH:MM:SS format - Mock time advancement for testing Includes reference solution, starter implementation, and comprehensive test suite covering all canonical data test cases.
Hey @kahgoh & @jagdish-15 , I'll review the failed checks. But can you please confirm the structure of the code and content? This is my first contribution to something like this, so my method was to copy an existing folder and modify to suit. Thanks! |
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.
This mostly looks good! But as you mentioned, you'll need to address the failed checks. The checkstyle
errors aren't too serious, but the test failure suggests there might be an issue with either your test or the example (proof) solution.
Also, just a heads-up, you don’t need to manually copy everything over. You can use configlet
to generate the basic structure and files for the exercise:
configlet 4.0.2
The official tool for managing Exercism language track repositories.
Usage:
configlet.exe [global-options] <command> [command-options]
Commands:
completion Output a completion script for a given shell
create Add a new exercise, approach or article
fmt Format the exercise 'config.json' files
generate Generate Concept Exercise 'introduction.md' files from 'introduction.md.tpl' files
info Print some information about the track
lint Check the track configuration for correctness
sync Check or update Practice Exercise docs, metadata, and tests from 'problem-specifications'.
Check or populate missing 'files' values for Concept/Practice Exercises from the track 'config.json'.
uuid Output new (version 4) UUIDs, suitable for the value of a 'uuid' key
Options for completion:
-s, --shell <shell> Choose the shell type (required)
Allowed values: b[ash], f[ish], z[sh]
Options for create:
--approach <slug> The slug of the approach
--article <slug> The slug of the article
--practice-exercise <slug> The slug of the practice exercise
--concept-exercise <slug> The slug of the concept exercise
-e, --exercise <slug> Only operate on this exercise
-o, --offline Do not update the cached 'problem-specifications' data
-a, --author The author of the exercise, approach or article
-d, --difficulty The difficulty of the exercise (default: 1)
Options for fmt:
-e, --exercise <slug> Only operate on this exercise
-u, --update Prompt to write formatted files
-y, --yes Auto-confirm the prompt from --update
Options for generate:
-e, --exercise <slug> Only operate on this exercise
-u, --update Prompt to write generated files
-y, --yes Auto-confirm the prompt from --update
Options for info:
-o, --offline Do not update the cached 'problem-specifications' data
Options for sync:
-e, --exercise <slug> Only operate on this exercise
-o, --offline Do not update the cached 'problem-specifications' data
-u, --update Prompt to update the unsynced track data
-y, --yes Auto-confirm prompts from --update for updating docs, filepaths, and metadata
--docs Sync Practice Exercise '.docs/introduction.md' and '.docs/instructions.md' files
--filepaths Populate empty 'files' values in Concept/Practice exercise '.meta/config.json' files
--metadata Sync Practice Exercise '.meta/config.json' metadata values
--tests [mode] Sync Practice Exercise '.meta/tests.toml' files.
The mode value specifies how missing tests are handled when using --update.
Allowed values: c[hoose], i[nclude], e[xclude] (default: choose)
Options for uuid:
-n, --num <int> Number of UUIDs to output
Global options:
-h, --help Show this help message and exit
--version Show this tool's version information and exit
-t, --track-dir <dir> Specify a track directory to use instead of the current directory
-v, --verbosity <verbosity> The verbosity of output.
Allowed values: q[uiet], n[ormal], d[etailed] (default: normal)
You can run ./gradlew test
to check your tests and ./gradlew check
for style issues.
And the author section in your exercise’s config.json
, it should contain only your GitHub username, not even the usernames of maintainers and definitely not what you have right now.
Also, make sure to add the exercise to the root config.json
as well. (You can see #2969 for an example, but if you do what I recommend below, you won't have to do it manually)
What I recommend is:
- Save your stub, proof solution, and test file somewhere temporarily.
- Delete the current folder for this exercise.
- Then re-generate it using
configlet
. (If you try to generate it now,configlet
will complain that the exercise already exists.)
You can set everything up manually if you really want to, but using configlet
will make it easier and ensure you're not missing anything.
git add . git commit -m "Add split-second-stopwatch exercise Implement the split-second-stopwatch practice exercise with: - State management (ready/running/stopped) - Time tracking for current lap and total elapsed time - Lap functionality with previous laps history - Start, stop, reset operations with proper state validation - Error handling for invalid state transitions - Time formatting in HH:MM:SS format - Mock time advancement for testing Includes reference solution, starter implementation, and comprehensive test suite covering all canonical data test cases."
Gradle files added to new practice exercise. Gradle/wrapper directories and files copied into split-second-stopwatch exercise as requested.
Prerequisites and difficulty updated in main config.json file.
config.json format updated.
config.json
Outdated
"exceptions", | ||
"if-else-statements" | ||
], | ||
"difficulty": 4 |
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 config.json
, the exercises are arranged by difficulty level. So you'll need to move this one to the end of the level 4 exercises, right before the level 5 ones begin.
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.
Hey @jagdish-15, I think they are (mostly) sorted by difficulty, then exercise name.
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.
@jagdish-15 , @kahgoh
I didn't check this because I thought any arrangements or sorting would have been done during the configlet ftm --update.
(though to be fair, I wouldn't have been aware...)
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.
@jagdish-15 ,
sorry for all the hassle with this one, but can you please specify what you mean by update config.json?
I know you mentioned some steps earlier on in the pull request, but I did follow the method of using configlet.Do you think I'll need to do so again?>
No worries @EmmanuelBerkowicz, by that I meant this, updating the position of this exercise in the config.json
in the root folder (not the exercise folder)!
@jagdish-15 , |
No worries! |
Add remaining gradle files to split-second-stopwatch exercise.
The lint is failing in the CI:
If you want to run the check locally, try running |
I'm sorry @kahgoh , but I'm a bit stuck here. I'm probably overlooking something simple, but I'm a bit stuck and would appreciate a hint :) |
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.
I'm sorry @kahgoh , but I'm a bit stuck here. I've tried a few different things to fix this, like running git renormalize commands and manually adding spaces to the end of each file and updating the line format settings in intelliJ before running the gradle test, but they all give me the same error.
I'm probably overlooking something simple, but I'm a bit stuck and would appreciate a hint :)
Just need to put a blank line at the end of the file ;) I've added them as suggestions below
exercises/practice/split-second-stopwatch/.meta/src/reference/java/SplitSecondStopwatch.java
Outdated
Show resolved
Hide resolved
exercises/practice/split-second-stopwatch/src/test/java/SplitSecondStopwatchTest.java
Outdated
Show resolved
Hide resolved
…econdStopwatchTest.java Co-authored-by: Kah Goh <[email protected]>
…java/SplitSecondStopwatch.java Co-authored-by: Kah Goh <[email protected]>
Now the |
@jagdish-15 , Do you think I'll need to do so again?> |
No, you won’t need to redo the configuration. What I meant in my earlier message is that we just need to update the position of the exercise in the I’ve also unresolved the conversation above where we discussed this earlier, so you can refer back to it easily! |
main config.json updated to reorder new practice exercise.
Add split-second-stopwatch exercise
Implement the split-second-stopwatch practice exercise with:
Includes reference solution, starter implementation, and comprehensive test suite covering all canonical data test cases.
pull request
Reviewer Resources:
Track Policies