The human body has many organs (heart, lungs, brain, and kidney, to name a few). We could think of the human body as complex object made up of simpler objects (organ).
a) Create classes for heart and brain. Think about what the functions of the heart and brain are in our body and map these functions into methods.
b) Create an organ class as the base class for the organs and derive the classes created earlier from the base class.

Recommended Answers

All 7 Replies

I really don't want to sound rude, or like I don't want to help people understant the basics of programming (which I do), but you should probably make an attempt at it before expecting people to just hand you the answers. You haven't even mentioned what part is troubling you.

Just having hard time understand what the question is asking for. I know they want classes, but can you eleborate for me?

You should have a base class called organ. You should also have two other classes called brain and heart, which inherit functionality from the organ class (because both of them are organs).

Basically, for every function the brain or heart carries out, create that function inside the appropriate class. If you can think of any functions that every organ in the body carries out, create that function inside the organ class.

Also, please use a meaningful title.

class Organs():

def __int__(self, heart, brain):

    self.heart = heart
    self.brain = brain
def __repr__(self):

    return self.heart()
def __repr__(self):

    return self.brain()

This is where I am stock and need little help with

You are still far off. Repeat the basics, read the assignment and explanation you got.

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.