#PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 3 "../ImmutableUnidirectionalOptionalNTest.ump" class Student(): #------------------------ # MEMBER VARIABLES #------------------------ #Student Attributes #Student Associations #Helper Variables #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aNumber, *allMentors): allMentors = list(allMentors) self._canSetMentors = None self._mentors = None self._number = None self._number = aNumber self._canSetMentors = True self._mentors = [] didAddMentors = self.setMentors(*allMentors) if not didAddMentors : raise RuntimeError ("Unable to create Student, must have 3 or fewer mentors, no duplicates. See https://manual.umple.org?RE001ViolationofImmutability.html") #------------------------ # INTERFACE #------------------------ def getNumber(self): return self._number # Code from template association_GetMany def getMentor(self, index): aMentor = self._mentors[index] return aMentor def getMentors(self): newMentors = tuple(self._mentors) return newMentors def numberOfMentors(self): self._number = len(self._mentors) return self._number def hasMentors(self): has = len(self._mentors) > 0 return has def indexOfMentor(self, aMentor): index = (-1 if not aMentor in self._mentors else self._mentors.index(aMentor)) return index # Code from template association_MinimumNumberOfMethod @staticmethod def minimumNumberOfMentors(): return 0 # Code from template association_MaximumNumberOfMethod @staticmethod def maximumNumberOfMentors(): return 3 # Code from template association_SetUnidirectionalOptionalN def setMentors(self, *newMentors): newMentors = list(newMentors) wasSet = False if not self._canSetMentors : return False self._canSetMentors = False verifiedMentors = [] for aMentor in newMentors: if (aMentor) in verifiedMentors : continue verifiedMentors.append(aMentor) if len(verifiedMentors) != len(newMentors) or len(verifiedMentors) > Student.maximumNumberOfMentors() : return wasSet self._mentors.clear() self._mentors.extend(verifiedMentors) wasSet = True return wasSet def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "number" + ":" + str(self.getNumber()) + "]" #PLEASE DO NOT EDIT THIS CODE #This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language! # line 9 "../ImmutableUnidirectionalOptionalNTest.ump" class Mentor(): #------------------------ # MEMBER VARIABLES #------------------------ #Mentor Attributes #------------------------ # CONSTRUCTOR #------------------------ def __init__(self, aName): self._name = None self._name = aName #------------------------ # INTERFACE #------------------------ def getName(self): return self._name def delete(self): pass def __str__(self): return str(super().__str__()) + "[" + "name" + ":" + str(self.getName()) + "]"