-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOOP11.py
More file actions
25 lines (25 loc) · 750 Bytes
/
Copy pathOOP11.py
File metadata and controls
25 lines (25 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#use of has-A relationshhip
class Car:
def __init__(self,model,price,name):
self.model=model
self.price=price
self.name=name
def getinfo(self):
print("Car model is: ",self.model)
print("Car Model name is: ",self.name)
print("Car price is: ",self.price)
class Emp:
def __init__(self,eno,ename,esal,car):
self.eno=eno
self.ename=ename
self.esal=esal
self.car=car
def disp(self):
print("Employee number is: ",self.eno)
print("Employee name is: ",self.ename)
print("Employee salary is: ",self.esal)
print("Employee car is:")
self.car.getinfo()
c=Car("SUVz",2500000,"Fortuner")
e=Emp(189,"Tejaswita",100000,c)
e.disp()