|
2 | 2 |
|
3 | 3 | Your task is to build a stopwatch to keep precise track of lap times. |
4 | 4 |
|
5 | | -The stopwatch uses four commands (Start, Stop, Lap, and Reset) to keep track of two things: |
| 5 | +The stopwatch uses four commands (Start, Stop, Lap, and Reset) to keep track of: |
6 | 6 |
|
7 | 7 | 1. The current lap's tracked time |
8 | | -2. Any previously recorded lap times |
| 8 | +2. Previously recorded lap times |
9 | 9 |
|
10 | 10 | What commands can be used depends on which state the stopwatch is in: |
11 | 11 |
|
12 | | -1. Ready (initial state) |
13 | | -2. Running (tracking time) |
14 | | -3. Stopped (not tracking time) |
| 12 | +1. Ready: initial state |
| 13 | +2. Running: tracking time |
| 14 | +3. Stopped: not tracking time |
15 | 15 |
|
16 | | -| Command | Begin state | End state | Effect | |
17 | | -| ------- | ----------- | --------- | ----------------------------------------------------------- | |
18 | | -| Start | Ready | Running | Start tracking time | |
19 | | -| Start | Stopped | Running | Resume tracking time | |
20 | | -| Stop | Running | Stopped | Stop tracking time | |
21 | | -| Lap | Running | Running | Add current lap to previous laps and then reset current lap | |
22 | | -| Reset | Stopped | Ready | Reset current lap and clear previous laps | |
23 | | - |
24 | | -TODO: add example of flow |
| 16 | +| Command | Begin state | End state | Effect | |
| 17 | +| ------- | ----------- | --------- | -------------------------------------------------------- | |
| 18 | +| Start | Ready | Running | Start tracking time | |
| 19 | +| Start | Stopped | Running | Resume tracking time | |
| 20 | +| Stop | Running | Stopped | Stop tracking time | |
| 21 | +| Lap | Running | Running | Add current lap to previous laps, then reset current lap | |
| 22 | +| Reset | Stopped | Ready | Reset current lap and clear previous laps | |
0 commit comments