Overwriting(OOP)

 ##by ineheritance we can make available the object of other

#in object of other class :-inheritance(think)
class animal:
def __init__(self,colour):
self.colour=colour
def introduce(self):
print("i am an animal")
def makesound(self):
print("making sound")
class dog(animal):
def makesound(self):
print("bow bow")
def takecare(self):
print("i am taking care of you")
class cat(animal):
def makesound(self):
print("meow meow")
wild_animal = animal("red")
puppy=dog("white")
kitten=cat("white")
puppy.makesound() ##object is use to call a method.
kitten.makesound()

"C:\Users\darul Haram\PycharmProjects\pythonProject2\venv\Scripts\python.exe" "C:/Users/darul Haram/PycharmProjects/pythonProject2/venv/Lib/Overwriting(OOP).py"
bow bow
meow meow

Process finished with exit code 0

Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions