18 lines
470 B
Python
18 lines
470 B
Python
#methodoverloading1.py
|
|
class Car:
|
|
def __init__(self, color, seats):
|
|
self.i_color = color
|
|
self.i_seat = seats
|
|
|
|
def print_me(self, i='basic'):
|
|
if(i =='basic'):
|
|
print(f"This car is of color {self.i_color}")
|
|
else:
|
|
print(f"This car is of color {self.i_color} with seats {self.i_seat}")
|
|
|
|
if __name__ == "__main__":
|
|
car = Car("blue", 5 )
|
|
car.print_me()
|
|
car.print_me('blah')
|
|
car.print_me('detail')
|