-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance_project.py
More file actions
51 lines (36 loc) · 1.43 KB
/
Copy pathinheritance_project.py
File metadata and controls
51 lines (36 loc) · 1.43 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 20 22:57:06 2022
@author: ŞEVVAL
"""
class Website(object):
"parent"
def __init__(self,name,surname):
self.name=name
self.surname=surname
def loginInfo(self):
print(self.name+" "+self.surname)
class Website1(Website):
"child"
def __init__(self,name,surname,ids):
Website.__init__(self,name,surname) #super methoduyla parent classtan direkt alınan constructor
#yeniden tanımlanabilir.
self.ids=ids
def login(self):
print(self.name+" "+self.surname+" "+self.ids)
#name ve surname parent classtan geldi.
#ids Website1 classında oluşturuldu.
class Website2(Website):
"child"
def __init__(self,name,surname,email):
Website.__init__(self,name,surname)
self.email=email
def login(self):
print(self.name+" "+self.surname+" "+self.email)
person1 = Website("nazli","acar")
person2 = Website1("sevval", "ilhan", "123")
person3 = Website2("utku", "acar", "email")
print(person2.login()) #sevval ilhan 123 -> child classtan gelen method
print(person2.loginInfo()) #sevval ilhan -> parent classtan gelen method
print(person3.login()) #utku acar email -> child classtan gelen method
print(person3.loginInfo()) #utku acar -> parent classtan gelen method