#PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../UnidirectionalMStarTest.ump" class Mentor(): #------------------------ # MEMBER VARIABLES #------------------------ #Mentor Attributes #Mentor Associations #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aName, *allStudents): allStudents = list(allStudents) self._students = None self._name = None self._name = aName self._students = [] didAddStudents = self.setStudents(*allStudents) if not didAddStudents : raise RuntimeError ("Unable to create Mentor, must have at least 1 students. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html") #------------------------ # INTERFACE #------------------------ def setName(self, aName): wasSet = False self._name = aName wasSet = True return wasSet def getName(self): return self._name # Code from template association_GetMany def getStudent(self, index): aStudent = self._students[index] return aStudent def getStudents(self): newStudents = tuple(self._students) return newStudents def numberOfStudents(self): number = len(self._students) return number def hasStudents(self): has = len(self._students) > 0 return has def indexOfStudent(self, aStudent): index = (-1 if not aStudent in self._students else self._students.index(aStudent)) return index # Code from template association_MinimumNumberOfMethod @staticmethod def minimumNumberOfStudents(): return 1 # Code from template association_AddUnidirectionalMStar def addStudent(self, aStudent): wasAdded = False if (aStudent) in self._students : return False self._students.append(aStudent) wasAdded = True return wasAdded def removeStudent(self, aStudent): wasRemoved = False if not (aStudent) in self._students : return wasRemoved if self.numberOfStudents() <= Mentor.minimumNumberOfStudents() : return wasRemoved self._students.remove(aStudent) wasRemoved = True return wasRemoved # Code from template association_SetUnidirectionalMStar def setStudents(self, *newStudents): newStudents = list(newStudents) wasSet = False verifiedStudents = [] for aStudent in newStudents: if (aStudent) in verifiedStudents : continue verifiedStudents.append(aStudent) if len(verifiedStudents) != len(newStudents) or len(verifiedStudents) < Mentor.minimumNumberOfStudents() : return wasSet self._students.clear() self._students.extend(verifiedStudents) wasSet = True return wasSet # Code from template association_AddIndexControlFunctions def addStudentAt(self, aStudent, index): wasAdded = False if self.addStudent(aStudent) : if index < 0 : index = 0 if index > self.numberOfStudents() : index = self.numberOfStudents() - 1 self._students.remove(aStudent) self._students.insert(index, aStudent) wasAdded = True return wasAdded def addOrMoveStudentAt(self, aStudent, index): wasAdded = False if (aStudent) in self._students : if index < 0 : index = 0 if index > self.numberOfStudents() : index = self.numberOfStudents() - 1 self._students.remove(aStudent) self._students.insert(index, aStudent) wasAdded = True else : wasAdded = self.addStudentAt(aStudent, index) return wasAdded def delete(self): self._students.clear() def __str__(self): return str(super().__str__()) + "[" + "name" + ":" + str(self.getName()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 9 "../UnidirectionalMStarTest.ump" class Student(): #------------------------ # MEMBER VARIABLES #------------------------ #Student Attributes #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aNumber): self._number = None self._number = aNumber #------------------------ # INTERFACE #------------------------ def setNumber(self, aNumber): wasSet = False self._number = aNumber wasSet = True return wasSet def getNumber(self): return self._number def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "number" + ":" + str(self.getNumber()) + "]"