I'm supposed to create three classes: a parent, and child 1 and child 2.
Child 1 and 2 are supposed to inherit from the Parent class.
So I believe I've done that.
class Parent:
"""Parent Object"""
def __init__(self):
self.greeting = "Hi I'm a Parent Object!"
class ChildA(Parent):
def __init__(self):
childclass.__init__(self)
self.childgreeting = "Hi I'm a Child Object!"
class ChildB(Parent):
pass
Now I have to write a parent object and the children objects which will print out their respective strings.
That's where I'm getting confused: I already put in the strings that they are a child or parent object within their classes.
But how do I get them to print as an object?
I've started out my code like this.
class Parent(object):
class ChildA(object):
class ChildB(object):
How to get those strings to print is bugging me.
And I have a feeling that my ChildA code for the class is not correct either.
Can anyone help me?
Parentis indeed a parent, then why do you haveChildAandChildBinheriting fromobject?childclass.__init__won't work since 'childclass' is not defined