File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # coding=utf-8
3+
4+ class SchoolKid :
5+ def __init__ (self , name , years ):
6+ self .name = name
7+ self .years = years
8+
9+ def get_name (self ):
10+ return self .name
11+
12+ def get_years (self ):
13+ return self .years
14+
15+ def change_name (self , new_name ):
16+ self .name = new_name
17+ return self .name
18+
19+ def change_years (self , new_years ):
20+ self .years = new_years
21+ return self .years
22+
23+
24+ class ExaggeratingKid (SchoolKid ):
25+ def get_years (self ):
26+ return self .years + 2
27+
28+
29+ if __name__ == "__main__" :
30+ tom = SchoolKid ("Tom" , 12 )
31+ print (tom .get_name ())
32+ print (tom .get_years ())
33+ tom .change_years (28 )
34+ print (tom .get_years ())
35+
36+ john = ExaggeratingKid ("John" , 13 )
37+ print (john .get_name ())
38+ print (john .get_years ())
You can’t perform that action at this time.
0 commit comments