Please send questions to
st10@humboldt.edu .
* intro to PyUnit
* import unittest:
import unittest
# requirements:
# 1. You want to write a GameDie class
# 2. GameDie has a constructor, it expects a desired number of
# sides, and it produces a game die instance with that many
# sides
# 3. GameDie includes accessors methods such as getNumSides,
# which returns the number of sides of that die,
# getNumRolls, how many times it has been rolled,
# and getLastRoll, the value of the latest roll
# 4. Its roll method should produce a value between 1 and the
# number of sides, should have the effect of changing the
# number of rolls and the last roll values for that die.
# this is the modiule to import to use PyUnit
import unittest
# in PyUnit, test cases are represented by the TestCase class in
# the unittest module
class NumSidesTestCase(unittest.TestCase):
# override the runTest method
def runTest(self):
(see rest of initial example in GameDie.py)