-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCricketer.py
More file actions
54 lines (40 loc) · 1.36 KB
/
Copy pathCricketer.py
File metadata and controls
54 lines (40 loc) · 1.36 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
52
53
54
# Example for Multiple Inheritance
class Cricketer:
def __init__(self, name, country, catches):
self.name = name
self.country = country
self.catches = catches
class Bowler(Cricketer):
def __init__(self, name, country, catches, wickets):
Cricketer.__init__(self, name, country, catches)
self.wickets = wickets
@property
def points(self):
return self.wickets // 5
def get_points(self):
return self.wickets // 5
class Batsman(Cricketer):
def __init__(self, name, country, catches, runs):
Cricketer.__init__(self, name, country, catches)
self.runs = runs
@property
def points(self):
return self.runs // 100
def get_points(self):
return self.runs // 100
class Allrounder(Batsman, Bowler):
def __init__(self, name, country, catches, wickets, runs):
Batsman.__init__(self, name, country, catches, runs)
Bowler.__init__(self, name, country, catches, wickets)
def print(self):
print(self.name, self.country, self.catches, self.wickets, self.runs)
@property
def points(self):
return Batsman.get_points(self) + Bowler.get_points(self)
# ba = Batsman("Xyz", "India", 10, 1000)
# bo = Bowler("Pqr", "Aus", 10, 250)
# print(ba.points)
# print(bo.points)
a = Allrounder("Abc", "India", 10, 50, 2000)
a.print()
print(a.points)