Last active
December 8, 2018 09:42
-
-
Save tance77/91a4a0c0de7c3217658cb758e35701f6 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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): | |
self.user_name = user_name | |
self.timer = timer | |
self.strikes = strike | |
def updateUser(strikes, timer): | |
self.strikes = strikes | |
self.timer = timer | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment