here is the task, I don't want anyone to do the coding for me. I just would really love if I got a starting point on how to begin this code. thank you. oh and this is in python program.

Recommended Answers

All 2 Replies

Hello Zahra!

I would make a Game class that holds the characters. Then I would make the characters that generates the attributes. The attributes are generated by rolling a dice.

Something like this:

# python 2 code

import random
class Dice(object):
    def __init__(self,sides):
    def roll(self):
        return random.randint(1,self.sides)

class Charachter(object):
    def __init__(self, name):
        self.attributes={"strength":0, "skill":0}

    def reset_attributes(self):
        for k in self.attributes.keys():

    def __str__(self):
         for k,v in self.attributes.iteritems():
              ret+="%s : %s\n" % (k,v)
         return ret

class Game(object):
    def __init__(self):

    def generate_charachters(self):

if __name__ == "__main__":
    for ch,attrs in g.charachters.iteritems():
         print ch
         print attrs

Next I would make a method in the charachter class that outputs the character data in some standardized way, possible a dictionary containing name and a dictionary of attributes. Then I would make the game class generate the two characters and save the data of the characters into a file.

The next move is to load the characters from this file...

thank you so much. i find it hard to start...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.