56 lines
2.6 KiB
Markdown
56 lines
2.6 KiB
Markdown
```
|
|
The MIT License (MIT)
|
|
|
|
Copyright (c) 2014, 2019, 2021 Exercism
|
|
Copyright (c) 2026 Networked Embedded Systems, University of Duisburg-Essen
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
```
|
|
|
|
# Introduction
|
|
|
|
You've always run for the thrill of it — no schedules, no timers, just the sound of your feet on the pavement.
|
|
But now that you've joined a competitive running crew, things are getting serious.
|
|
Training sessions are timed to the second, and every split second counts.
|
|
To keep pace, you've picked up the _Split-Second Stopwatch_ — a sleek, high-tech gadget that's about to become your new best friend.
|
|
|
|
|
|
# Instructions
|
|
|
|
Your task is to build a stopwatch to keep precise track of lap times.
|
|
|
|
The stopwatch uses four commands (start, stop, lap, and reset) to keep track of:
|
|
|
|
1. The current lap's tracked time
|
|
2. Previously recorded lap times
|
|
|
|
What commands can be used depends on which state the stopwatch is in:
|
|
|
|
1. Ready: initial state
|
|
2. Running: tracking time
|
|
3. Stopped: not tracking time
|
|
|
|
| Command | Begin state | End state | Effect |
|
|
| ------- | ----------- | --------- | -------------------------------------------------------- |
|
|
| Start | Ready | Running | Start tracking time |
|
|
| Start | Stopped | Running | Resume tracking time |
|
|
| Stop | Running | Stopped | Stop tracking time |
|
|
| Lap | Running | Running | Add current lap to previous laps, then reset current lap |
|
|
| Reset | Stopped | Ready | Reset current lap and clear previous laps |
|