-
-
Notifications
You must be signed in to change notification settings - Fork 554
Add split-second-stopwatch
exercise
#2547
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
Changes from 7 commits
6e77b12
4a4b8cd
e04156c
b9ad75b
09fb9b1
45e8721
6ba2dc4
75ec01c
c2dde7b
9f60c46
4c038c8
31f0e40
c325d0f
3bbfb6a
653ada6
432b543
93cd3f4
c801dbb
ded5b17
0f8be5a
948fe9c
f02d447
e6e7d9c
10a7c15
76afe8d
20911be
65f7f72
d942dbd
8276e71
4f1d130
3570883
4e0afd1
e09f643
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,194 @@ | ||
{ | ||
"exercise": "split-second-stopwatch", | ||
"comments": ["Times are formatted as 'HH:mm:ss'."], | ||
"cases": [ | ||
IsaacG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"description": "new stopwatch", | ||
"cases": [ | ||
{ | ||
"uuid": "ddb238ea-99d4-4eaa-a81d-3c917a525a23", | ||
"description": "starts in ready state", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "state", | ||
"expected": "ready" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "8a892c1e-9ef7-4690-894e-e155a1fe4484", | ||
"description": "new stopwatch does not have previous laps", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "previousLaps", | ||
"expected": [] | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "b19635d4-08ad-4ac3-b87f-aca10e844071", | ||
"description": "current lap has no elapsed time", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "currentLap", | ||
"expected": "00:00:00" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "492eb532-268d-43ea-8a19-2a032067d335", | ||
"description": "total has no time elapsed", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "total", | ||
"expected": "00:00:00" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "start", | ||
"cases": [ | ||
{ | ||
"uuid": "5b2705b6-a584-4042-ba3a-4ab8d0ab0281", | ||
"description": "changes state to running", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "state", | ||
"expected": "running" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "748235ce-1109-440b-9898-0a431ea179b6", | ||
"description": "does not change previous laps", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "previousLaps", | ||
"expected": [] | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "491487b1-593d-423e-a075-aa78d449ff1f", | ||
"description": "starts time tracking in current lap", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "advanceTime", | ||
"seconds": 5 | ||
}, | ||
{ | ||
"command": "currentLap", | ||
"expected": "00:00:05" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "a0a7ba2c-8db6-412c-b1b6-cb890e9b72ed", | ||
"description": "starts time tracking in total", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "advanceTime", | ||
"seconds": 23 | ||
}, | ||
{ | ||
"command": "total", | ||
"expected": "00:00:23" | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
}, | ||
{ | ||
"uuid": "7f558a17-ef6d-4a5b-803a-f313af7c41d3", | ||
"description": "cannot be called from running state", | ||
"property": "time", | ||
"input": { | ||
"commands": [ | ||
{ | ||
"command": "new" | ||
}, | ||
{ | ||
"command": "start" | ||
}, | ||
{ | ||
"command": "start", | ||
"expected": { | ||
"error": "cannot start an already running stopwatch" | ||
} | ||
} | ||
] | ||
}, | ||
"expected": {} | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||||
# Instructions | ||||||
ErikSchierboom marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
Your task is to build a stopwatch that can be used to keep track of lap times. | ||||||
The stopwatch has the following functionality: | ||||||
|
||||||
- Start: start/resume time tracking | ||||||
- Stop: stop (pause) time tracking | ||||||
- Current lap: the time tracked for the current lap | ||||||
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
The other list items use a verb to indicate what we're doing with the tracked time.
ErikSchierboom marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
- Previous laps: the times of all previously recorded laps | ||||||
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
The other list items use a verb to indicate what we're doing with the tracked time. 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. Also is this the running total or all the individual lap times? 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. "display" implies "STDOUT" to me, which isn't used in most tracks/exercises. 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. Track the time then? 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. Track could work. What would your preference be Isaac? BTW I agree with Isaac's sentiment 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. Retrieve the previously recorded lap times? I'm not sure if "track" would imply an implementation detail. 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. I also had a lot of trouble with current lap and previous laps when I initially reviewed. I intentionally left out the verbs because I wasn't sure what an appropriate verb would be. I intended to ask a question but completely forgot about it before posting the review. |
||||||
- Reset: stop time tracking, reset the current lap, and clear all previously recorded laps | ||||||
- Lap: add the current lap time to the previous laps and start a new lap | ||||||
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. This line is unclear. Are we adding the lap time to a running total or keeping a history of the previous laps? 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. Well, sort of both. Lap does not influence the total running time, it's just a cutoff point where the current lap time is basically "stopped", then added to the previous laps and then the current lap time is reset in order to start counting from zero again |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Introduction | ||
|
||
As an amateur runner, you've never really felt the need to track your time precisely. | ||
However, having just enrolled in a local running team, you're now following precisely timed training sessions, each one tuned to the second. | ||
Because of this, you've decided to get the _split-second stopwatch_, a basic but very precise stopwatch. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
title = "Split-second Stopwatch" | ||
ErikSchierboom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
blurb = "Keep track of time through a digital stopwatch." | ||
source = "Erik Schierboom" | ||
source_url = "https://github.com/exercism/problem-specifications/pull/TODO" |
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 may not be clear in terms of "What do these letters mean". I mean to say that it may be intuitive that it is hour, minutes, seconds, but why the change in case for hours?
It can be useful to show a time where the
HH
is put in place, such as 13:14:15, to show the difference from a 12 hour clock to a twenty four hour clock. To others, it will be clear, but via experience rather than inherent knowledge.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.
Fair point! I'll update