class / instance question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • belinda thom

    #1

    class / instance question

    Hello,

    I'm hoping the Python community knows whether or not the following is
    possible, and if it is possible, how I would go about writing code to
    do this.

    I've written two game classes---Nim and TicTacToe---where each
    derives from a Game class that I've created (it is essentially an
    abstract base class, where I've used an "abstract() " hack to somewhat
    enforce this).

    I now want to be able to pass either of these classes into a game-
    playing engine, for instance a function

    playGame(classO fGameToBePlayed ) :

    # inside of which I create a new game using that class's constructor

    Is this possible, and if so, how to approach it?

    Thanks a lot,

    --b
Working...