Last active
December 8, 2018 09:42
-
-
Save tance77/91a4a0c0de7c3217658cb758e35701f6 to your computer and use it in GitHub Desktop.
Revisions
-
tance77 revised this gist
Dec 8, 2018 . No changes.There are no files selected for viewing
-
tance77 revised this gist
Dec 8, 2018 . 1 changed file with 19 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,30 @@ probation_manager = ProbationManager() probation_manager.updateUser('BobbRoss', 600, 1) # update should handle adding or updating class ProbationManager: def __init__(self): self.probed_users = [] def addUser(self, user_name, timer, strikes = 1) #strikes defaults to 1 if no value is passed in user = ProbedUser(user_name, timer, strikes) self.probed_users.append(user) return user # return the newly creted user def updateUser(self, target_user, timer, strikes = 1): for user in self.probed_users: # user is a ProbedUser if update_user == user.user_name: user.updateUser(strikes, timer) return user return self.addUser(target_user, timer, strikes) def userOnProbation(self, target_user): for user in self.probed_users: if target_user == user.user_name: # user is already on probation return user # return the found user # user is not in the list return None # return nothing because nothing was found class ProbationUser: def __init__(self, user_name, timer, strikes = 1): -
tance77 revised this gist
Dec 8, 2018 . 1 changed file with 17 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,28 @@ probation_manager = ProbationManager() for user in probation_manger.probed_users: if token[1] == user.user_name': # user is already on probation user.updateUser(strikes,timer) else: # first strike probation_manager.addUser(new ProbationUser(token[1], timer)) class ProbationManager: def __init__(self): self.probed_users = [] def addUser(self, probed_user) self.probed_users.append(probed_user) def removeUser(self, probed_user) self.probed_users.remove(probed_user) class ProbationUser: def __init__(self, user_name, timer, strikes = 1): self.user_name = user_name self.timer = timer self.strikes = strike -
tance77 created this gist
Dec 8, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ users_on_probation = [] for user in users_on_probation: if token[1] == user.user['user_name']: # user is already on probation user.updateUser(strikes,timer) else: # first strike users_on_probation.append(new ProbationUser(user, timer)) class ProbationUser: def __init__(self, user, timer, strikes = 1): self.user = user self.timer = timer self.strikes = strike def updateUser(strikes, timer): self.strikes = strikes self.timer = timer