I am a beginning Programmer using Python and am having trouble wrapping my head around WHY I would create a class. Procedural programming I get, but object orientation I would like a little help with.
Say I was creating a GURPS character and I wanted to store his stats.
Easy peasy! But how, and more importantly WHY would I do this as an object?
name = raw_input ("What is your characters name?")
str = raw_input ("What is your characters Strength score?")
int = raw_input ("What is your characters Intelegence score?")
dex = raw_input ("What is your characters Dexterity score?")
heal = raw_input ("What is your characters Health score?")
#print your character
print "Strength: ",str
print "Intelegence: ",int
print "Dexterity: ",dex
print "Health: ",heal
I just cant wrap my mind around it. I've been searching the internet for a dialog about why one would use Objects and Classes and Functions,and cannot seem to find one which is understandable. Is it is just "the norm"?
"""this class is the player character"""
def __init__(self,name =None,str=None,dex=None,heal=None,int=None):
self.name = name
self.str = str
self.dex = dex
self.heal = heal
self.int = int
Thanks for your input,