generated from mwc/lab_dice
Add assessment
This commit is contained in:
parent
1d8878f10a
commit
90a550c778
|
@ -0,0 +1,25 @@
|
|||
# Dice Lab Assessment
|
||||
|
||||
Everything works as expected. Nice work!
|
||||
|
||||
## Checkpoint 1
|
||||
|
||||
Checking the endpoints of the range (e.g. `listOfFaces[0] == listOfFaces[1]
|
||||
and listOfFaces[0] == listOfFaces[2]` was a clever way to accomplish this.
|
||||
|
||||
## Checkpoint 2
|
||||
|
||||
The content of your docstrings looks good. However, most are above their function
|
||||
rather than inside it. This technically works, but defeats some of the purpose of
|
||||
docstrings, as there are automated tools that use them and expect to find them in
|
||||
the right place.
|
||||
|
||||
## Checkpoint 3
|
||||
|
||||
Looks good. Just looking at your code for small straight, I wasn't sure it was correct,
|
||||
so I wrote a few simple tests in `test_small_straight.py`. Everything works :)
|
||||
|
||||
## Comments
|
||||
|
||||
Thanks for thoughtful log messages. Indeed, D&D and other games are often excellent contexts
|
||||
for OOP.
|
|
@ -0,0 +1,25 @@
|
|||
from die import Die
|
||||
from yahtzee_goals import GoalSmallStraight
|
||||
|
||||
def make_dice(faces):
|
||||
"""Given a list of face values, returns corresponding dice.
|
||||
This is a helper method used to make testing easier.
|
||||
"""
|
||||
dice = []
|
||||
for face in faces:
|
||||
die = Die()
|
||||
die.face = face
|
||||
dice.append(die)
|
||||
return dice
|
||||
|
||||
def test_small_straight(faces, expected):
|
||||
"""Tests whether small straight works correctly.
|
||||
"""
|
||||
goal = GoalSmallStraight()
|
||||
result = goal.is_small_straight(make_dice(faces))
|
||||
assert(result == expected)
|
||||
|
||||
test_small_straight([1, 1, 2, 3, 4], True)
|
||||
test_small_straight([4, 1, 1, 2, 3], True)
|
||||
test_small_straight([2, 3, 4, 5, 5], True)
|
||||
test_small_straight([1, 3, 3, 4, 5], False)
|
Loading…
Reference in New Issue