diff --git a/assessment.md b/assessment.md new file mode 100644 index 0000000..7cd4115 --- /dev/null +++ b/assessment.md @@ -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. diff --git a/test_yahtzee_goals.py b/test_yahtzee_goals.py new file mode 100644 index 0000000..f066895 --- /dev/null +++ b/test_yahtzee_goals.py @@ -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)