From d98a738d481fbf227bae60729237a094274a162b Mon Sep 17 00:00:00 2001 From: Kamila Bobkowska Date: Sat, 2 May 2020 15:10:49 +0000 Subject: [PATCH] updating for individual projecet --- models/dumpster.py | 170 +++++++++++++++++++++++---------------------- 1 file changed, 86 insertions(+), 84 deletions(-) diff --git a/models/dumpster.py b/models/dumpster.py index 4cd3078..d88dc2f 100644 --- a/models/dumpster.py +++ b/models/dumpster.py @@ -1,84 +1,86 @@ -import numpy as np -import pygame - -class trash(): - def __init__(self): - self.id = 0 - self.plastic = 0 - self.paper = 0 - self.mixed = 0 - self.organic = 0 - self.glass = 0 - self.color = 0 - self.xy = 0 - self.value = 1 - - def giveID(self,id): - self.id = id - - - - def throwAway(self): - trash = np.random.randint(1,6) - if trash == 1: - self.plastic += 1 - return True - elif trash == 2: - self.paper += 1 - return True - elif trash == 3: - self.glass += 1 - return True - elif trash == 4: - self.organic += 1 - return True - elif trash == 5: - self.mixed += 1 - return True - else: - return False - - - def empty(self): - if self.plastic > 0: - self.plastic -= 1 - print("taking plastic") - return True - elif self.paper > 0: - self.paper -= 1 - print("taking paper") - return True - elif self.glass > 0: - self.glass -= 1 - print("taking glass") - return True - elif self.organic > 0: - self.organic -= 1 - print("taking organic") - return True - elif self.mixed > 0: - self.mixed -= 1 - print("taking mixed") - return True - else: - print("can't take trash from this dumpster") - return False - - def colour(self): - if self.plastic > 0: - self.color = 1 - return True - elif self.paper > 0: - self.color = 2 - return True - elif self.glass > 0: - self.color = 3 - return True - elif self.organic > 0: - self.color = 4 - return True - elif self.mixed > 0: - self.color = 5 - return True - else: - return False +import numpy as np +import pygame + +class trash(): + def __init__(self): + self.id = 0 + self.plastic = 0 + self.paper = 0 + self.mixed = 0 + self.organic = 0 + self.glass = 0 + self.color = 0 + self.xy = 0 + self.value = 1 + self.numberx = 0 + self.numbery = 0 + + def giveID(self,id): + self.id = id + + + + def throwAway(self): + trash = np.random.randint(1,6) + if trash == 1: + self.plastic += 1 + return True + elif trash == 2: + self.paper += 1 + return True + elif trash == 3: + self.glass += 1 + return True + elif trash == 4: + self.organic += 1 + return True + elif trash == 5: + self.mixed += 1 + return True + else: + return False + + + def empty(self): + if self.plastic > 0: + self.plastic -= 1 + print("taking plastic") + return True + elif self.paper > 0: + self.paper -= 1 + print("taking paper") + return True + elif self.glass > 0: + self.glass -= 1 + print("taking glass") + return True + elif self.organic > 0: + self.organic -= 1 + print("taking organic") + return True + elif self.mixed > 0: + self.mixed -= 1 + print("taking mixed") + return True + else: + print("can't take trash from this dumpster") + return False + + def colour(self): + if self.plastic > 0: + self.color = 1 + return True + elif self.paper > 0: + self.color = 2 + return True + elif self.glass > 0: + self.color = 3 + return True + elif self.organic > 0: + self.color = 4 + return True + elif self.mixed > 0: + self.color = 5 + return True + else: + return False