class / instance question

B

belinda thom

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(classOfGameToBePlayed) :

# 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top