-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclassPerson.py
More file actions
97 lines (88 loc) · 2.95 KB
/
classPerson.py
File metadata and controls
97 lines (88 loc) · 2.95 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class Person:
''' The class Person describes a person'''
count = 0
def __init__(self, name, DOB, address):
'''
Objective: To initialize object of class Person
Input Parameters:
self (implicit parameter) - object of type Person
name - string
DOB - string (Date of Birth)
address - string
Return Value: None
'''
self.name = name
self.DOB = DOB
self.address = address
Person.count += 1
def getName(self):
'''
Objective: To retrieve name of the person
Input Parameter: self (implicit parameter) - object of type Person
Return Value: name - string
'''
return self.name
def getDOB(self):
'''
Objective: To retrieve the date of birth of a person
Input Parameter: self (implicit parameter) - object of type Person
Return Value: DOB - string
'''
return self.DOB
def getAddress(self):
'''
Objective: To retrieve address of person
Input Parameter: self (implicit parameter) - object of type Person
Return Value: address - string
'''
return self.address
def setName(self, name):
'''
Objective: To update name of person
Input Parameter: self (implicit parameter) - object of type Person
name – string value
Return Value: None
'''
self.name = name
def setDOB(self, DOB):
'''
Objective: To update DOB of person
Input Parameter: self (implicit parameter) - object of type Person
DOB – string value
Return Value: None
'''
self.DOB = DOB
def setAddress(self, address):
'''
Objective: To update address of person
Input Parameter: self (implicit parameter) - object of type Person
address – string value
Return Value: None
'''
self.address = address
def getCount(self):
'''
Objective: To get count of objects of type Person
Input Parameter: self (implicit parameter) - object of type Person
Return Value: count: numeric
'''
return Person.count
def __str__(self):
'''
Objective: To return string representation of object of type Person
Input Parameter: self (implicit parameter)- object of type
Person
Return Value: string
'''
return 'Name:'+self.name+'\nDOB:'+str(self.DOB)+'\nAddress:'+self.address
def __del__(self):
'''
Objective: To be invoked on deletion of an instance of the
class Person
Input Parameter:
self (implicit parameter) – object of type Person
Return Value: None
'''
#approach: decrement the class variable count
print('Deleted..!')
Person.count -= 1