Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • my text adventure

    0 answers - 1861 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    i am attempting to write a dig function that will create rooms.
    i have succeeded only in getting a headache :)
    any suggestions on where i am going wrong would
    be super helpful.
    Hi David,
    You may want to write a unit test to make sure that all the methods of
    your class are doing the right thing. The issue with programs is that,
    when something goes wrong, any component might be responsible: unit tests
    allow us to get more confidence that all components are working.
    (And actually, they is something wrong with one of your helper functions;
    that's why I'm encouraging writing the proper test cases. *grin*)
    Here's one that will help point out a problem:
    import unittest
    class TestRoom(unittest.TestCase):
    def testNorthF(self):
    room1 = Room('startroom',[0,0])
    self.assertEqual([0, 1], room1.nextdoor('n'))
    def testSouthF(self):
    room1 = Room('startroom',[0,0])
    self.assertEqual([0, -1], room1.nextdoor('s'))
    def testEastF(self):
    room1 = Room('startroom',[0,0])
    self.assertEqual([1, 0], room1.nextdoor('e'))
    def testWestF(self):
    room1 = Room('startroom',[0,0])
    self.assertEqual([-1, 0], room1.nextdoor('w'))
    if __name__ == '__main__':
    unittest.main()
    Do these tests make sense? It's just making sure that nextdoor is doing
    something reasonable and returning the proper coordinates that we expect.
    Try testing your code, and you should see something.
    For a more comprehensive example of unit testing, you might want to look
    at:
    which has a good long-running example of Python's unittest module.
    Hope this helps!
    Tutor maillist - Tutor (AT) python (DOT) org

Re: my text adventure


max 4000 letters.
Your nickname that display:
In order to stop the spam: 0 + 9 =
QUESTION ON "Python"

EMSDN.COM