-
Notifications
You must be signed in to change notification settings - Fork 0
/
people.py
47 lines (38 loc) · 1.25 KB
/
people.py
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
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# People Object
# Takes in a filename, gets information and initializes Person class for each
# instance of a Person in the data file
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class People():
numPeople = 0
people = []
def __init__(self, filename):
self.getPeople(filename)
def getPeople(self, filename):
f = open(filename)
arr = []
for i, j in enumerate(f): arr.append(j)
self.numPeople = i + 1
self.people = [0] * (self.numPeople)
for j in range(i + 1):
self.people[j] = Person(arr[j], j)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Person Object
# Takes in a full line from a people file, gets information and sets it
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class Person():
personId = 0
name = ""
availability = []
def __init__(self, line, pid):
self.setName(line)
self.setAvailability(line)
self.setId(pid)
def setName(self, line):
words = line.split()
self.name = words[0]
def setAvailability(self, line):
words = line.split()
self.availability = words[1]
def setId(self, pid):
self.personId = pid