diff --git a/philosopher_example/controleurPhilosophersExample.py b/philosopher_example/controleurPhilosophersExample.py index 52b271af63e09c21c2dd49dabe57afebcfb914b9..3a54ae01734f31fc238c61f57ec58530dcae2599 100644 --- a/philosopher_example/controleurPhilosophersExample.py +++ b/philosopher_example/controleurPhilosophersExample.py @@ -8,6 +8,8 @@ class ControleurPhilosophersExample(Controleur): def __init__(self, fenetre, amas): super().__init__(fenetre, amas) self.__philosophers = [] + self.__left = [] + self.__right = [] self.__numberPhilosopher = 10 self.__barChart = [] self.__barChart.append(self.addBarChart('Eaten Pastas')) @@ -49,9 +51,12 @@ class ControleurPhilosophersExample(Controleur): y = 100 * sin(2 * pi * i / self.__numberPhilosopher) + (heightCanvas / 2) carre = self.draw_rectangle(x, y, 20, 20, 'green') - self.draw_rectangle(x - 15, y, 20, 7, 'black') + left = self.draw_rectangle(x - 15, y, 20, 7, 'black') + right = self.draw_rectangle(x + 15, y, 20, 7, 'white') self.__philosophers.append(carre) + self.__left.append(left) + self.__right.append(right) nom = 'Mr ' + str(i) @@ -77,11 +82,11 @@ class ControleurPhilosophersExample(Controleur): coords = self.get_coords_element(self.__philosophers[i]) if agents[i].get_Left_Fork().owned(agents[i]): - self.draw_rectangle(coords[0] - 15, coords[1], 20, 7, 'black') + self.change_color(self.__left[i],'black') else: - self.draw_rectangle(coords[0] - 15, coords[1], 20, 7, 'white') + self.change_color(self.__left[i],'white') if agents[i].get_Right_Fork().owned(agents[i]): - self.draw_rectangle(coords[0] + 15, coords[1], 20, 7, 'black') + self.change_color(self.__right[i],'black') else: - self.draw_rectangle(coords[0] + 15, coords[1], 20, 7, 'white') + self.change_color(self.__right[i],'white')