-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPerson.py
More file actions
54 lines (47 loc) · 1.81 KB
/
Person.py
File metadata and controls
54 lines (47 loc) · 1.81 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
################################################################################
# File name: Person.py
# Author: Debbie Heisler
# Date: April 4, 2014
# Description:
# This class represents a person. It contains their first name,
# last name, and email address. It can print out itself
################################################################################
""" Person class contains methods and members to describe one person """
class Person:
def __init__(self, fn, ln, em):
""" Initialize a person with the give first name,
last name, and email address
"""
self.firstName = fn
self.lastName = ln
self.email = em
def printToScreen(self):
""" Prints the person information to the screen """
formatted = '\t' + self.firstName + '\t\t' + self.lastName + \
'\t\t' + self.email
print(formatted)
def printToFile(self, fn):
""" Prints the person information to the given file, fn """
formatted = self.firstName + "," + self.lastName + "," + self.email + "\n"
fn.write(formatted)
def inFirstName(self, match):
""" Returns true if match is contained in the first name.
False otherwise. Case insensitive """
if (self.firstName.lower().find(match.lower()) < 0):
return False
else:
return True
def inLastName(self, match):
""" Returns true if match is contained in the last name.
False otherwise. Case insensitive """
if (self.lastName.lower().find(match.lower()) < 0):
return False
else:
return True
def inEmail(self, match):
""" Returns true if match is contained in the email address.
False otherwise. Case insensitive """
if (self.email.lower().find(match.lower()) < 0):
return False
else:
return True