-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonClass.py
More file actions
32 lines (19 loc) · 843 Bytes
/
PersonClass.py
File metadata and controls
32 lines (19 loc) · 843 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
# This is a part of a fictitious family sorting process
# Here, only one instance of a last name can exist
class Person:
def __init__(self, firstName, lastName):
self.firstName = firstName
self.lastName = lastName
def getFName(self):
return self.firstName
def getLName(self):
return self.lastName
# Objects are considered equal if they have the same last name
# They are in the same equivalence class/ coset depending on how you look at it
def __eq__(self, other):
return self.getLName() == other.getLName()
Henry = Person("Henry", "Jones")
June = Person("June", "Jones")
print("Hi, my name is " + Henry.getFName() + " " + Henry.getLName())
print("Hi, my name is " + June.getFName() + " " + June.getLName())
print(Henry == June)