-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdated_PLD.py
More file actions
270 lines (233 loc) · 7.8 KB
/
Updated_PLD.py
File metadata and controls
270 lines (233 loc) · 7.8 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
class User:
userlist = []
id = 0
def __init__(self, name, email, password):
self.name = name
self.email = email
self.password = password
User.userlist.append(self)
@property
def name(self):
return self.__name
@name.setter
def name(self, value):
try:
if not all(x.isalpha() or x.isspace() for x in value):
raise ValueError
except ValueError:
print("Name should only contain letters or spaces")
while not all(x.isalpha() or x.isspace() for x in value):
value = input("Re-enter your name:")
self.__name = value
@property
def email(self):
return self.__email
@email.setter
def email(self, value):
try:
if "@" not in value or ".com" not in value:
raise SyntaxError
except SyntaxError:
print("Enter proper email")
value = input("Re-enter your email:")
self.__email = value
@property
def password(self):
return self.__password
@password.setter
def password(self, value):
self.__password = value
@staticmethod
def record_info():
User.id += 1
name = input("Enter your name: ")
email = input("Enter your email: ")
password = input("Enter your password: ")
return name, email, password
@staticmethod
def login():
uemail = input("Enter email: ")
pword = input("Enter password: ")
for i in User.userlist:
if uemail != i.email:
continue
if pword != i.password:
print("Password is incorrect")
return None
return i
print("Email not found")
return None
class Seeker(User):
def __init__(self, name, email, password, description, skills):
super().__init__(name, email, password)
self.description = description
self.skills = skills
@property
def description(self):
return self.__description
@description.setter
def description(self, value):
self.__description = value
@property
def skills(self):
return self.__skills
@skills.setter
def skills(self, value):
self.__skills = value
@staticmethod
def record_info():
name, email, password = User.record_info()
skills = input("Enter your skills (Separate each skill by a comma): ")
description = input("Enter a description for your profile: ")
return Seeker(name, email, password, description, skills.replace(" ", "").lower().split(","))
def recommended(self):
recs = []
count = 0
for i in joblist:
count = 0 # Reset count for each job
for j in i.required_skills:
if str(j).strip().lower() in self.skills:
count += 1
if (count / len(i.required_skills)) > 0.6:
recs.append(i)
return recs
def display_recs(self):
recs = self.recommended()
for i in recs:
print(f"{' ' * 20}Title: {i.title}")
print("Description: ", i.description)
print("Required Skills: ", i.required_skills)
print(f"Posted by {i.employer.name}")
print("Select option:")
print("1. Go back")
print("2. Exit")
print("OR Enter the id of the job you wish to apply to")
x = input()
if x == '1':
return
elif x == '2':
exit()
else:
self.apply(x)
def apply(self, job_id):
for job in joblist:
if str(job.id) == job_id:
job.applicants.append(self)
print(f"Successfully applied for the job: {job.title}")
return
print("Invalid job ID. Application failed.")
class Employer(User):
def __init__(self, name, email, password, jobs):
super().__init__(name, email, password)
self.jobs = jobs
self.applicants = []
@staticmethod
def record_info():
name, email, password = User.record_info()
return Employer(name, email, password, [])
def post_job(self):
name = input("Enter name of the job: ")
skills = input("Enter required skills (separated by comma): ")
description = input("Enter job description: ")
job_obj = Job(self, name, skills.split(","), description)
self.jobs.append(job_obj)
joblist.append(job_obj)
print(f"Job '{name}' successfully posted.")
def see_applicants(self):
if not self.jobs:
print("No jobs posted yet.")
return
for job in self.jobs:
print(f"Job Title: {job.title}")
print("Applicants:")
for applicant in job.applicants:
print(f" - {applicant.name}")
print()
class Job:
num_of_instances = 0
def __init__(self, employer, title, skills, description):
Job.num_of_instances += 1
self.employer = employer
self.id = Job.num_of_instances
self.title = title
self.required_skills = skills
self.description = description
self.applicants = []
userlist = []
joblist = []
if __name__ == "__main__":
while True:
print("Welcome to JobJet")
print("-" * 40)
print("Select user type:")
print("1. Job Seeker")
print("2. Employer")
print("3. Exit")
choice = input()
if choice == "1":
obj = None
choice2 = None
while obj is None:
print("Select option:")
print("1. Log into account")
print("2. Create a new account")
print("3. Exit")
choice2 = input()
if choice2 == "1":
obj = User.login()
elif choice2 == "2":
obj = Seeker.record_info()
elif choice2 == "3":
break
else:
print("Invalid choice")
continue
if obj is not None:
while True:
print("Select option:")
print("1. View recommended jobs")
print("2. Go back")
choice3 = input()
if choice3 == "1":
obj.display_recs()
elif choice3 == "2":
break
else:
print("Invalid choice")
elif choice == "2":
obj = None
choice2 = None
while obj is None:
print("Select option:")
print("1. Log into account")
print("2. Create a new account")
print("3. Exit")
choice2 = input()
if choice2 == "1":
obj = User.login()
elif choice2 == "2":
obj = Employer.record_info()
elif choice2 == "3":
break
else:
print("Invalid choice")
continue
if obj is not None:
while True:
print("Select option:")
print("1. Post a job")
print("2. See applicants")
print("3. Go back")
choice3 = input()
if choice3 == "1":
obj.post_job()
elif choice3 == "2":
obj.see_applicants()
elif choice3 == "3":
break
else:
print("Invalid choice")
elif choice == "3":
break
else:
print("Invalid choice")