forked from gqdw/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperson.py
More file actions
44 lines (35 loc) · 897 Bytes
/
Copy pathperson.py
File metadata and controls
44 lines (35 loc) · 897 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
"""
for test class
"""
class Person:
def __init__(self, name, job=None, pay=0):
self.name = name
self.job = job
self.pay = pay
def lastName(self):
return self.name.split()[-1]
def giveRaise(self, percent):
self.pay = int(self.pay * (1 + percent))
def __str__(self):
return '[Person: %s, %s]' % (self.name, self.pay)
class Manager(Person):
def giveRaise(self, percent, bonus=.10):
Person.giveRaise(self, percent + bonus)
def __init__(self, name, pay):
Person.__init__(self, name, 'mgr', pay)
if __name__ == '__main__':
bob = Person('bob smith')
sue = Person('sue jones', job='dev', pay=100000)
# print bob.name, bob.pay
# print sue.name, sue.pay
# print bob.lastName(), sue.lastName()
tom = Manager('tom jones', 50000)
tom.giveRaise(.10)
print bob
print sue
sue.giveRaise(.10)
print sue
# print sue.pay
print tom.lastName()
print tom