Thread: Why OOP?
View Single Post
Old Oct 7th, 2007, 10:55 AM   #27
nisim777
Newbie
 
Join Date: May 2005
Posts: 17
Rep Power: 0 nisim777 is on a distinguished road
re:

Here is what I've been playing with to create the database. I know it needs to be more in depth because the result will be different if they examine, jump, put, etc.

[PHP]VERBS = ["examine", "look", "jump"]
NOUNS = {"head":"you see a head", "basket":"you see a basket"}

choice = raw_input("What would you like to do? ")

for verb in VERBS:
if verb in choice:
for noun in NOUNS:
if noun in choice:
print NOUNS[noun]

raw_input("Press enter to exit. ")[/PHP]

I did this mainly to figure out how to separate the data from a raw_input() statement. Would you suggest creating a separate dictionary for each type of verb? For example, instead of just NOUNS{}, I would have a JUMP_NOUNS{}, EX_NOUNS{}, PUT_NOUNS{}, and the dictionary definitions would be different based on which verb they use? Is their an easier or better way to do it?
nisim777 is offline   Reply With Quote