#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Mentor:
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Object:
def __init__(self):
pass
def delete(self):
pass
def example_obj(self, g):
# line 3 "MethodParameterTypes.ump"
#implementation
pass
# end line
def example_bool(self, b):
pass
def example_int(self, i):
pass
def example_float(self, f):
pass
def example_double(self, d):
pass
def example_string(self, s):
pass
def example_obj_array(self, gs):
pass
def example_primitive_array(self, is_):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
Name = "XYZ"
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
import datetime
class Mentor:
MAX = 100
MIN = -99
HELLO = "Hello"
nextX = 1
mentorsByX = {}
mentorsById = {}
def __init__(self, aStr, aD, aI, aId):
self._str = aStr
self._canSetStr2 = True
self._str2 = None
self._someName = None
self._lDoub = 0.0
self._lBool = False
self._name = "Johannes"
self._d = aD
self._t = datetime.time.fromisoformat("12:00:00")
self._i = aI
self._x = 0
self._id = None
self._p = None
self._q = "chicken"
self._r = None
self._s = "123"
self._tt = datetime.date.fromisoformat("1978-12-25")
self._u = datetime.time.fromisoformat("12:13:14")
self._v = None
self._w = None
self.resetP()
self.resetR()
self.resetV()
self.resetW()
self._x = __class__.nextX
__class__.nextX += 1
__class__.mentorsByX[self._x] = self
if not self.setId(aId):
raise RuntimeError("Cannot create due to duplicate id. See https://manual.umple.org?RE003ViolationofUniqueness.html")
def setStr2(self, aStr2):
if not self._canSetStr2:
return False
self._canSetStr2 = False
self._str2 = aStr2
return True
def setSomeName(self, aSomeName):
self._someName = aSomeName
return True
def setLDoub(self, aLDoub):
self._lDoub = aLDoub
return True
def setLBool(self, aLBool):
self._lBool = aLBool
return True
def setName(self, aName):
self._name = aName
return True
def setD(self, aD):
self._d = aD
return True
def setI(self, aI):
self._i = aI
return True
def setId(self, aId):
anOldId = self._id
if anOldId is not None and anOldId == aId:
return True
if __class__.hasWithId(aId):
return False
self._id = aId
if anOldId is not None:
__class__.mentorsById.pop(anOldId, None)
__class__.mentorsById[aId] = self
return True
def setP(self, aP):
self._p = aP
return True
def resetP(self):
self._p = self.getDefaultP()
return True
def setQ(self, aQ):
self._q = aQ
return True
def setR(self, aR):
self._r = aR
return True
def resetR(self):
self._r = self.getDefaultR()
return True
def setTt(self, aTt):
self._tt = aTt
return True
def setU(self, aU):
self._u = aU
return True
def setV(self, aV):
self._v = aV
return True
def resetV(self):
self._v = self.getDefaultV()
return True
def setW(self, aW):
self._w = aW
return True
def resetW(self):
self._w = self.getDefaultW()
return True
def getStr(self):
return self._str
def getStr2(self):
return self._str2
def getSomeName(self):
return self._someName
def getLDoub(self):
return self._lDoub
def getLBool(self):
return self._lBool
def getName(self):
return self._name
def getD(self):
return self._d
def getI(self):
return self._i
def getDerivedTwiceI(self):
return self._i * 2
def getId(self):
return self._id
@staticmethod
def getWithId(aId):
return __class__.mentorsById.get(aId)
@staticmethod
def hasWithId(aId):
return __class__.getWithId(aId) is not None
def getP(self):
return self._p
def getDefaultP(self):
return "robot"
def getQ(self):
return self._q
def getR(self):
return self._r
def getDefaultR(self):
return ""
def getS(self):
return self._s
def getTt(self):
return self._tt
def getU(self):
return self._u
def getV(self):
return self._v
def getDefaultV(self):
return datetime.date.fromisoformat("1978-12-26")
def getW(self):
return self._w
def getDefaultW(self):
return datetime.time.fromisoformat("12:59:59")
def getX(self):
return self._x
@staticmethod
def getWithX(aX):
return __class__.mentorsByX.get(aX)
@staticmethod
def hasWithX(aX):
return __class__.getWithX(aX) is not None
def isLBool(self):
return self._lBool
def delete(self):
if __class__.mentorsByX.get(self._x) is self:
del __class__.mentorsByX[self._x]
if __class__.mentorsById.get(self._id) is self:
del __class__.mentorsById[self._id]
def __str__(self):
return (super().__str__() + "["
+ "x:" + str(self.getX()) + ","
+ "str:" + str(self.getStr()) + ","
+ "str2:" + str(self.getStr2()) + ","
+ "someName:" + str(self.getSomeName()) + ","
+ "lDoub:" + str(self.getLDoub()) + ","
+ "lBool:" + str(self.getLBool()) + ","
+ "name:" + str(self.getName()) + ","
+ "i:" + str(self.getI()) + ","
+ "derivedTwiceI:" + str(self.getDerivedTwiceI()) + ","
+ "id:" + str(self.getId()) + ","
+ "p:" + str(self.getP()) + ","
+ "q:" + str(self.getQ()) + ","
+ "r:" + str(self.getR()) + ","
+ "s:" + str(self.getS())
+ "]"
+ "\n d=" + ("null" if self.getD() is None else "this" if self.getD() is self else str(self.getD()).replace(" ", " "))
+ "\n tt=" + ("null" if self.getTt() is None else "this" if self.getTt() is self else str(self.getTt()).replace(" ", " "))
+ "\n u=" + ("null" if self.getU() is None else "this" if self.getU() is self else str(self.getU()).replace(" ", " "))
+ "\n v=" + ("null" if self.getV() is None else "this" if self.getV() is self else str(self.getV()).replace(" ", " "))
+ "\n w=" + ("null" if self.getW() is None else "this" if self.getW() is self else str(self.getW()).replace(" ", " ")))
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Mentor:
def __init__(self, aCapacity, aId, aName):
self._capacity = aCapacity
self._id = aId
self._name = aName
def setCapacity(self, aCapacity):
self._capacity = aCapacity
return True
def setId(self, aId):
self._id = aId
return True
def setName(self, aName):
self._name = aName
return True
def getCapacity(self):
return self._capacity
def getId(self):
return self._id
def getName(self):
return self._name
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "capacity:" + str(self.getCapacity()) + ","
+ "id:" + str(self.getId()) + ","
+ "name:" + str(self.getName())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from NetworkNode import NetworkNode
from enum import Enum
class Router(NetworkNode):
class Status(Enum):
disconnected = "disconnected"
connected = "connected"
def __str__(self):
return self.value
def __init__(self, aIpAddress):
self._ipAddress = aIpAddress
self._status = None
self._deleted = False
self.setStatus(__class__.Status.disconnected)
def getStatusFullName(self):
answer = str(self._status)
return answer
def getStatus(self):
return self._status
def createConnection(self):
if self._deleted:
return False
wasEventProcessed = False
aStatus = self._status
if aStatus is __class__.Status.disconnected:
self.setStatus(__class__.Status.connected)
wasEventProcessed = True
return wasEventProcessed
def disconnectRequest(self):
if self._deleted:
return False
wasEventProcessed = False
aStatus = self._status
if aStatus is __class__.Status.connected:
self.setStatus(__class__.Status.disconnected)
wasEventProcessed = True
return wasEventProcessed
def setStatus(self, aStatus):
self._status = aStatus
def delete(self):
self._deleted = True
def connect(self):
return False
def disconnect(self):
return False
def errorDetected(self):
return False
def __str__(self):
return (super().__str__() + "["
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from NetworkNode import NetworkNode
from enum import Enum
class Router(NetworkNode):
class Status(Enum):
disconnected = "disconnected"
connected = "connected"
def __str__(self):
return self.value
def __init__(self, aIpAddress):
self._ipAddress = aIpAddress
self._status = None
self._deleted = False
self.setStatus(__class__.Status.disconnected)
def getStatusFullName(self):
answer = str(self._status)
return answer
def getStatus(self):
return self._status
def connect(self):
if self._deleted:
return False
wasEventProcessed = False
aStatus = self._status
if aStatus is __class__.Status.disconnected:
self.setStatus(__class__.Status.connected)
wasEventProcessed = True
return wasEventProcessed
def disconnect(self):
if self._deleted:
return False
wasEventProcessed = False
aStatus = self._status
if aStatus is __class__.Status.connected:
self.setStatus(__class__.Status.disconnected)
wasEventProcessed = True
return wasEventProcessed
def errorDetected(self):
if self._deleted:
return False
wasEventProcessed = False
aStatus = self._status
if aStatus is __class__.Status.connected:
self.setStatus(__class__.Status.disconnected)
wasEventProcessed = True
return wasEventProcessed
def setStatus(self, aStatus):
self._status = aStatus
def delete(self):
self._deleted = True
def __str__(self):
return (super().__str__() + "["
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from NetworkNode import NetworkNode
from enum import Enum
class Router(NetworkNode):
class Status(Enum):
disconnected = "disconnected"
connected = "connected"
def __str__(self):
return self.value
def __init__(self, aIpAddress):
self._ipAddress = aIpAddress
self._status = None
self._deleted = False
self.setStatus(__class__.Status.disconnected)
def getStatusFullName(self):
answer = str(self._status)
return answer
def getStatus(self):
return self._status
def connect(self):
if self._deleted:
return False
wasEventProcessed = False
aStatus = self._status
if aStatus is __class__.Status.disconnected:
self.setStatus(__class__.Status.connected)
wasEventProcessed = True
return wasEventProcessed
def disconnect(self):
if self._deleted:
return False
wasEventProcessed = False
aStatus = self._status
if aStatus is __class__.Status.connected:
self.setStatus(__class__.Status.disconnected)
wasEventProcessed = True
return wasEventProcessed
def setStatus(self, aStatus):
self._status = aStatus
def delete(self):
self._deleted = True
def errorDetected(self):
return False
def __str__(self):
return (super().__str__() + "["
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Mentor:
def __init__(self):
pass
def delete(self):
pass
def showMe(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Teacher:
def __init__(self):
self._myStudents = []
def getMyStudent(self, index):
return self._myStudents[index]
def getMyStudents(self):
return tuple(self._myStudents)
def numberOfMyStudents(self):
return len(self._myStudents)
def hasMyStudents(self):
return len(self._myStudents) > 0
def indexOfMyStudent(self, aMyStudent):
return next((i for i, x in enumerate(self._myStudents) if x is aMyStudent), -1)
@staticmethod
def minimumNumberOfMyStudents():
return 0
def addMyStudent(self, aMyStudent):
if any(x is aMyStudent for x in self._myStudents):
return False
existingTeacher = aMyStudent.getTeacher()
isNewTeacher = existingTeacher is not None and existingTeacher is not self
if isNewTeacher:
if not aMyStudent.setTeacher(self):
return False
else:
self._myStudents.append(aMyStudent)
return True
def removeMyStudent(self, aMyStudent):
if aMyStudent.getTeacher() is self:
return False
index = next((i for i, x in enumerate(self._myStudents) if x is aMyStudent), -1)
if index >= 0:
del self._myStudents[index]
return True
def addMyStudentAt(self, aMyStudent, index):
if not self.addMyStudent(aMyStudent):
return False
if index < 0:
index = 0
if index > self.numberOfMyStudents():
index = self.numberOfMyStudents() - 1
del self._myStudents[next((i for i, x in enumerate(self._myStudents) if x is aMyStudent), -1)]
self._myStudents.insert(index, aMyStudent)
return True
def addOrMoveMyStudentAt(self, aMyStudent, index):
if not any(x is aMyStudent for x in self._myStudents):
return self.addMyStudentAt(aMyStudent, index)
if index < 0:
index = 0
if index > self.numberOfMyStudents():
index = self.numberOfMyStudents() - 1
del self._myStudents[next((i for i, x in enumerate(self._myStudents) if x is aMyStudent), -1)]
self._myStudents.insert(index, aMyStudent)
return True
def delete(self):
for i in range(len(self._myStudents), 0, -1):
aMyStudent = self._myStudents[i - 1]
aMyStudent.delete()
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Registration:
def __init__(self, aGrade, aStudent, aCourseSection):
self._cachedHashCode = None
self._canSetStudent = True
self._canSetCourseSection = True
self._grade = aGrade
self._student = None
self._courseSection = None
if not self.setStudent(aStudent):
raise RuntimeError("Unable to create registration due to student. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
if not self.setCourseSection(aCourseSection):
raise RuntimeError("Unable to create registration due to courseSection. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
def setGrade(self, aGrade):
self._grade = aGrade
return True
def getGrade(self):
return self._grade
def getStudent(self):
return self._student
def getCourseSection(self):
return self._courseSection
def setStudent(self, aStudent):
if not self._canSetStudent:
return False
if aStudent is None:
return False
existingStudent = self._student
self._student = aStudent
index = -1
if existingStudent is not None and existingStudent is not aStudent:
index = existingStudent.indexOfRegistration(self)
existingStudent.removeRegistration(self)
if not self._student.addRegistration(self):
self._student = existingStudent
if index >= 0 and existingStudent.indexOfRegistration(self) < 0:
existingStudent._registrations.insert(index, self)
return False
return True
def setCourseSection(self, aCourseSection):
if not self._canSetCourseSection:
return False
if aCourseSection is None:
return False
existingCourseSection = self._courseSection
self._courseSection = aCourseSection
index = -1
if existingCourseSection is not None and existingCourseSection is not aCourseSection:
index = existingCourseSection.indexOfRegistration(self)
existingCourseSection.removeRegistration(self)
if not self._courseSection.addRegistration(self):
self._courseSection = existingCourseSection
if index >= 0 and existingCourseSection.indexOfRegistration(self) < 0:
existingCourseSection._registrations.insert(index, self)
return False
return True
def __eq__(self, obj):
if type(obj) is not type(self):
return NotImplemented
return (self.getStudent(), self.getCourseSection()) == (obj.getStudent(), obj.getCourseSection())
def __hash__(self):
if self._cachedHashCode is None:
self._cachedHashCode = hash((self.getStudent(), self.getCourseSection()))
self._canSetStudent = False
self._canSetCourseSection = False
return self._cachedHashCode
def equals(self, obj):
return self == obj
def delete(self):
placeholderStudent = self._student
self._student = None
if placeholderStudent is not None:
placeholderStudent.removeRegistration(self)
placeholderCourseSection = self._courseSection
self._courseSection = None
if placeholderCourseSection is not None:
placeholderCourseSection.removeRegistration(self)
def __str__(self):
return (super().__str__() + "["
+ "grade:" + str(self.getGrade())
+ "]"
+ "\n student = " + ("null" if self.getStudent() is None else format(id(self.getStudent()), "x"))
+ "\n courseSection = " + ("null" if self.getCourseSection() is None else format(id(self.getCourseSection()), "x")))
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Registration:
def __init__(self, aGrade, aStudent, aCourseSection):
self._cachedHashCode = None
self._canSetStudent = True
self._canSetCourseSection = True
self._grade = aGrade
self._student = None
self._courseSection = None
if not self.setStudent(aStudent):
raise RuntimeError("Unable to create registration due to student. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
if not self.setCourseSection(aCourseSection):
raise RuntimeError("Unable to create registration due to courseSection. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
def setGrade(self, aGrade):
self._grade = aGrade
return True
def getGrade(self):
return self._grade
def getStudent(self):
return self._student
def getCourseSection(self):
return self._courseSection
def setStudent(self, aStudent):
if not self._canSetStudent:
return False
if aStudent is None:
return False
existingStudent = self._student
self._student = aStudent
index = -1
if existingStudent is not None and existingStudent is not aStudent:
index = existingStudent.indexOfRegistration(self)
existingStudent.removeRegistration(self)
if not self._student.addRegistration(self):
self._student = existingStudent
if index >= 0 and existingStudent.indexOfRegistration(self) < 0:
existingStudent._registrations.insert(index, self)
return False
return True
def setCourseSection(self, aCourseSection):
if not self._canSetCourseSection:
return False
if aCourseSection is None:
return False
existingCourseSection = self._courseSection
self._courseSection = aCourseSection
index = -1
if existingCourseSection is not None and existingCourseSection is not aCourseSection:
index = existingCourseSection.indexOfRegistration(self)
existingCourseSection.removeRegistration(self)
if not self._courseSection.addRegistration(self):
self._courseSection = existingCourseSection
if index >= 0 and existingCourseSection.indexOfRegistration(self) < 0:
existingCourseSection._registrations.insert(index, self)
return False
return True
def __eq__(self, obj):
if type(obj) is not type(self):
return NotImplemented
return (self.getStudent(), self.getCourseSection()) == (obj.getStudent(), obj.getCourseSection())
def __hash__(self):
if self._cachedHashCode is None:
self._cachedHashCode = hash((self.getStudent(), self.getCourseSection()))
self._canSetStudent = False
self._canSetCourseSection = False
return self._cachedHashCode
def equals(self, obj):
return self == obj
def delete(self):
placeholderStudent = self._student
self._student = None
if placeholderStudent is not None:
placeholderStudent.removeRegistration(self)
placeholderCourseSection = self._courseSection
self._courseSection = None
if placeholderCourseSection is not None:
placeholderCourseSection.removeRegistration(self)
def __str__(self):
return (super().__str__() + "["
+ "grade:" + str(self.getGrade())
+ "]"
+ "\n student = " + ("null" if self.getStudent() is None else format(id(self.getStudent()), "x"))
+ "\n courseSection = " + ("null" if self.getCourseSection() is None else format(id(self.getCourseSection()), "x")))
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
"""This is a student"""
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Foo:
def __init__(self):
self._bars = []
def getBar(self, index):
return self._bars[index]
def getBars(self):
"""* I am a multiline comment above an association."""
return tuple(self._bars)
def numberOfBars(self):
return len(self._bars)
def hasBars(self):
return len(self._bars) > 0
def indexOfBar(self, aBar):
return next((i for i, x in enumerate(self._bars) if x is aBar), -1)
@staticmethod
def minimumNumberOfBars():
return 0
def addBar1(self):
from Bar import Bar
return Bar(self)
def addBar2(self, aBar):
if any(x is aBar for x in self._bars):
return False
existingFoo = aBar.getFoo()
isNewFoo = existingFoo is not None and existingFoo is not self
if isNewFoo:
if not aBar.setFoo(self):
return False
else:
self._bars.append(aBar)
return True
def addBar(self, *args, **kwargs):
from Bar import Bar
bound = __class__._bindArguments(("aBar",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Bar)):
return __class__.addBar2(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.addBar1(self, *bound)
raise TypeError("No method matches provided parameters")
def removeBar(self, aBar):
if aBar.getFoo() is self:
return False
index = next((i for i, x in enumerate(self._bars) if x is aBar), -1)
if index >= 0:
del self._bars[index]
return True
def addBarAt(self, aBar, index):
if not self.addBar2(aBar):
return False
if index < 0:
index = 0
if index > self.numberOfBars():
index = self.numberOfBars() - 1
del self._bars[next((i for i, x in enumerate(self._bars) if x is aBar), -1)]
self._bars.insert(index, aBar)
return True
def addOrMoveBarAt(self, aBar, index):
if not any(x is aBar for x in self._bars):
return self.addBarAt(aBar, index)
if index < 0:
index = 0
if index > self.numberOfBars():
index = self.numberOfBars() - 1
del self._bars[next((i for i, x in enumerate(self._bars) if x is aBar), -1)]
self._bars.insert(index, aBar)
return True
def delete(self):
for i in range(len(self._bars), 0, -1):
aBar = self._bars[i - 1]
aBar.delete()
@staticmethod
def _bindArguments(names, varargs, args, kwargs):
if len(args) > len(names) and not varargs:
return None
bound = list(args[:len(names)])
for name in names[len(bound):]:
if name not in kwargs:
return None
bound.append(kwargs[name])
if len(kwargs) != len(names) - min(len(args), len(names)):
return None
if varargs:
bound.append(args[len(names):])
return bound
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
def __init__(self):
self._grade = ""
def setGrade(self, aGrade):
self._grade = aGrade
return True
def getGrade(self):
return self._grade
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "grade:" + str(self.getGrade())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Token:
def __init__(self, aP):
self._p = aP
def setP(self, aP):
self._p = aP
return True
def getP(self):
return self._p
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "]"
+ "\n p=" + ("null" if self.getP() is None else "this" if self.getP() is self else str(self.getP()).replace(" ", " ")))
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
"""
This is a student
Multiple comments
on several lines
"""
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from abc import ABC
class Foo(ABC):
def __init__(self):
if type(self) is __class__:
raise TypeError("Can't instantiate abstract class Foo")
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Foo:
"""
* I am a class comment.
*
* Notice how there are 4 empty lines below me.
*
*
*
*
* And 2 below me.
*
*
* These lines should come out as we see here.
* Comments such as these are often used to improve readability through whitespace clarity.
"""
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Foo:
def __init__(self, aName):
self._name = aName
def setName(self, aName):
self._name = aName
return True
def getName(self):
"""* I am a multiline comment above an attribute."""
return self._name
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "name:" + str(self.getName())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Token:
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Foo:
def __init__(self, aTestAttribute1, aTestAttribute2, aTestAttribute3, aTestAttribute4):
self._testAttribute1 = aTestAttribute1
self._testAttribute2 = aTestAttribute2
self._testAttribute3 = aTestAttribute3
self._testAttribute4 = aTestAttribute4
def setTestAttribute1(self, aTestAttribute1):
self._testAttribute1 = aTestAttribute1
return True
def setTestAttribute2(self, aTestAttribute2):
self._testAttribute2 = aTestAttribute2
return True
def setTestAttribute3(self, aTestAttribute3):
self._testAttribute3 = aTestAttribute3
return True
def setTestAttribute4(self, aTestAttribute4):
self._testAttribute4 = aTestAttribute4
return True
def getTestAttribute1(self):
"""Inline comment above attribute."""
return self._testAttribute1
def getTestAttribute2(self):
"""
Multiple inline comments
above attribute.
"""
return self._testAttribute2
def getTestAttribute3(self):
"""Multiline comment above attribute."""
return self._testAttribute3
def getTestAttribute4(self):
"""
* Multiple multiline comments
* above attribute.
"""
return self._testAttribute4
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "testAttribute1:" + str(self.getTestAttribute1()) + ","
+ "testAttribute2:" + str(self.getTestAttribute2()) + ","
+ "testAttribute3:" + str(self.getTestAttribute3()) + ","
+ "testAttribute4:" + str(self.getTestAttribute4())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from example.Mentor import Mentor
class SubMentor(Mentor):
def __init__(self, aName):
super().__init__(aName)
def delete(self):
super().delete()
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from example.Mentor import Mentor
class SubMentor2(Mentor):
def __init__(self, aName, aSubName):
self._subName = aSubName
super().__init__(aName)
def setSubName(self, aSubName):
self._subName = aSubName
return True
def getSubName(self):
return self._subName
def delete(self):
super().delete()
def __str__(self):
return (super().__str__() + "["
+ "subName:" + str(self.getSubName())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Token:
def __init__(self):
self._positions = []
def addPosition(self, aPosition):
self._positions.append(aPosition)
return True
def removePosition(self, aPosition):
if aPosition not in self._positions:
return False
self._positions.remove(aPosition)
return True
def getPosition(self, index):
return self._positions[index]
def getPositions(self):
return list(self._positions)
def numberOfPositions(self):
return len(self._positions)
def hasPositions(self):
return len(self._positions) > 0
def indexOfPosition(self, aPosition):
return self._positions.index(aPosition) if aPosition in self._positions else -1
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Mentor:
def __init__(self, aName):
self._name = aName
self._student = None
def setName(self, aName):
self._name = aName
return True
def getName(self):
return self._name
def getStudent(self):
return self._student
def hasStudent(self):
return self._student is not None
def setStudent(self, aStudent):
existingStudent = self._student
if existingStudent is None:
if aStudent is None or not aStudent.addMentor(self):
return False
else:
if existingStudent.numberOfMentors() <= existingStudent.minimumNumberOfMentors():
return False
existingStudent.removeMentor(self)
if aStudent is not None:
aStudent.addMentor(self)
self._student = aStudent
return True
def delete(self):
if self._student is not None:
if self._student.numberOfMentors() <= 1:
self._student.delete()
else:
placeholderStudent = self._student
self._student = None
placeholderStudent.removeMentor(self)
def __str__(self):
return (super().__str__() + "["
+ "name:" + str(self.getName())
+ "]"
+ "\n student = " + ("null" if self.getStudent() is None else format(id(self.getStudent()), "x")))
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
def __init__(self, aNumber, *allMentors):
self._number = aNumber
self._mentors = []
self._courses = []
if not self.setMentors(*allMentors):
raise RuntimeError("Unable to create Student, must have at least 1 mentors. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
def setNumber(self, aNumber):
self._number = aNumber
return True
def getNumber(self):
return self._number
def getMentor(self, index):
return self._mentors[index]
def getMentors(self):
return tuple(self._mentors)
def numberOfMentors(self):
return len(self._mentors)
def hasMentors(self):
return len(self._mentors) > 0
def indexOfMentor(self, aMentor):
return next((i for i, x in enumerate(self._mentors) if x is aMentor), -1)
def getCourse(self, index):
return self._courses[index]
def getCourses(self):
return tuple(self._courses)
def numberOfCourses(self):
return len(self._courses)
def hasCourses(self):
return len(self._courses) > 0
def indexOfCourse(self, aCourse):
return next((i for i, x in enumerate(self._courses) if x is aCourse), -1)
@staticmethod
def minimumNumberOfMentors():
return 1
def addMentor(self, aMentor):
if any(x is aMentor for x in self._mentors):
return False
existingStudent = aMentor.getStudent()
if existingStudent is not None and existingStudent.numberOfMentors() <= self.minimumNumberOfMentors():
return False
if existingStudent is not None:
index = next((i for i, x in enumerate(existingStudent._mentors) if x is aMentor), -1)
if index >= 0:
del existingStudent._mentors[index]
self._mentors.append(aMentor)
aMentor._student = self
return True
def removeMentor(self, aMentor):
index = next((i for i, x in enumerate(self._mentors) if x is aMentor), -1)
if index < 0 or self.numberOfMentors() <= self.minimumNumberOfMentors():
return False
del self._mentors[index]
aMentor._student = None
return True
def setMentors(self, *newMentors):
if len(newMentors) < self.minimumNumberOfMentors():
return False
checkNewMentors = set()
studentToNewMentors = {}
for aMentor in newMentors:
if id(aMentor) in checkNewMentors:
return False
existingStudent = aMentor.getStudent()
if existingStudent is not None and existingStudent is not self:
nextCount = studentToNewMentors.get(id(existingStudent), existingStudent.numberOfMentors()) - 1
if nextCount < 1:
return False
studentToNewMentors[id(existingStudent)] = nextCount
checkNewMentors.add(id(aMentor))
for orphan in self._mentors:
if id(orphan) not in checkNewMentors:
orphan._student = None
self._mentors.clear()
for aMentor in newMentors:
existingStudent = aMentor.getStudent()
if existingStudent is not None:
index = next((i for i, x in enumerate(existingStudent._mentors) if x is aMentor), -1)
if index >= 0:
del existingStudent._mentors[index]
aMentor._student = self
self._mentors.append(aMentor)
return True
def addMentorAt(self, aMentor, index):
if not self.addMentor(aMentor):
return False
if index < 0:
index = 0
if index > self.numberOfMentors():
index = self.numberOfMentors() - 1
del self._mentors[next((i for i, x in enumerate(self._mentors) if x is aMentor), -1)]
self._mentors.insert(index, aMentor)
return True
def addOrMoveMentorAt(self, aMentor, index):
if not any(x is aMentor for x in self._mentors):
return self.addMentorAt(aMentor, index)
if index < 0:
index = 0
if index > self.numberOfMentors():
index = self.numberOfMentors() - 1
del self._mentors[next((i for i, x in enumerate(self._mentors) if x is aMentor), -1)]
self._mentors.insert(index, aMentor)
return True
@staticmethod
def minimumNumberOfCourses():
return 0
def addCourse(self, aCourse):
if any(x is aCourse for x in self._courses):
return False
self._courses.append(aCourse)
if aCourse.indexOfStudent(self) == -1 and not aCourse.addStudent(self):
del self._courses[next((i for i, x in enumerate(self._courses) if x is aCourse), -1)]
return False
return True
def removeCourse(self, aCourse):
oldIndex = next((i for i, x in enumerate(self._courses) if x is aCourse), -1)
if oldIndex == -1:
return False
del self._courses[oldIndex]
if aCourse.indexOfStudent(self) != -1 and not aCourse.removeStudent(self):
self._courses.insert(oldIndex, aCourse)
return False
return True
def addCourseAt(self, aCourse, index):
if not self.addCourse(aCourse):
return False
if index < 0:
index = 0
if index > self.numberOfCourses():
index = self.numberOfCourses() - 1
del self._courses[next((i for i, x in enumerate(self._courses) if x is aCourse), -1)]
self._courses.insert(index, aCourse)
return True
def addOrMoveCourseAt(self, aCourse, index):
if not any(x is aCourse for x in self._courses):
return self.addCourseAt(aCourse, index)
if index < 0:
index = 0
if index > self.numberOfCourses():
index = self.numberOfCourses() - 1
del self._courses[next((i for i, x in enumerate(self._courses) if x is aCourse), -1)]
self._courses.insert(index, aCourse)
return True
def delete(self):
for aMentor in self._mentors:
aMentor._student = None
self._mentors.clear()
copyOfCourses = tuple(self._courses)
self._courses.clear()
for aCourse in copyOfCourses:
aCourse.removeStudent(self)
def __str__(self):
return (super().__str__() + "["
+ "number:" + str(self.getNumber())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Course:
def __init__(self):
self._students = []
def getStudent(self, index):
return self._students[index]
def getStudents(self):
return tuple(self._students)
def numberOfStudents(self):
return len(self._students)
def hasStudents(self):
return len(self._students) > 0
def indexOfStudent(self, aStudent):
return next((i for i, x in enumerate(self._students) if x is aStudent), -1)
@staticmethod
def minimumNumberOfStudents():
return 0
def addStudent(self, aStudent):
if any(x is aStudent for x in self._students):
return False
self._students.append(aStudent)
if aStudent.indexOfCourse(self) == -1 and not aStudent.addCourse(self):
del self._students[next((i for i, x in enumerate(self._students) if x is aStudent), -1)]
return False
return True
def removeStudent(self, aStudent):
oldIndex = next((i for i, x in enumerate(self._students) if x is aStudent), -1)
if oldIndex == -1:
return False
del self._students[oldIndex]
if aStudent.indexOfCourse(self) != -1 and not aStudent.removeCourse(self):
self._students.insert(oldIndex, aStudent)
return False
return True
def addStudentAt(self, aStudent, index):
if not self.addStudent(aStudent):
return False
if index < 0:
index = 0
if index > self.numberOfStudents():
index = self.numberOfStudents() - 1
del self._students[next((i for i, x in enumerate(self._students) if x is aStudent), -1)]
self._students.insert(index, aStudent)
return True
def addOrMoveStudentAt(self, aStudent, index):
if not any(x is aStudent for x in self._students):
return self.addStudentAt(aStudent, index)
if index < 0:
index = 0
if index > self.numberOfStudents():
index = self.numberOfStudents() - 1
del self._students[next((i for i, x in enumerate(self._students) if x is aStudent), -1)]
self._students.insert(index, aStudent)
return True
def delete(self):
copyOfStudents = tuple(self._students)
self._students.clear()
for aStudent in copyOfStudents:
aStudent.removeCourse(self)
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Application:
theInstance = None
def __init__(self):
if __class__.theInstance is not self:
raise RuntimeError("Application is a singleton, so use Application.getInstance()")
@staticmethod
def getInstance():
if __class__.theInstance is None:
__class__.theInstance = __class__.__new__(__class__)
try:
__class__.theInstance.__init__()
except BaseException:
__class__.theInstance = None
raise
return __class__.theInstance
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Mentor:
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from Person import Person
class Teacher(Person):
def __init__(self, aName, aAge, aPosition):
self._position = aPosition
self._students = []
super().__init__(aName, aAge)
def setPosition(self, aPosition):
self._position = aPosition
return True
def getPosition(self):
return self._position
def getStudent(self, index):
return self._students[index]
def getStudents(self):
return tuple(self._students)
def numberOfStudents(self):
return len(self._students)
def hasStudents(self):
return len(self._students) > 0
def indexOfStudent(self, aStudent):
return next((i for i, x in enumerate(self._students) if x is aStudent), -1)
@staticmethod
def minimumNumberOfStudents():
return 0
def addStudent1(self, aName, aAge, aStudentID):
from Student import Student
return Student(aName, aAge, aStudentID, self)
def addStudent2(self, aStudent):
if any(x is aStudent for x in self._students):
return False
existingTeacher = aStudent.getTeacher()
isNewTeacher = existingTeacher is not None and existingTeacher is not self
if isNewTeacher:
if not aStudent.setTeacher(self):
return False
else:
self._students.append(aStudent)
return True
def addStudent(self, *args, **kwargs):
from Student import Student
bound = __class__._bindArguments(("aStudent",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Student)):
return __class__.addStudent2(self, *bound)
bound = __class__._bindArguments(("aName", "aAge", "aStudentID"), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], str)) and (isinstance(bound[1], int) and not isinstance(bound[1], bool)) and (isinstance(bound[2], int) and not isinstance(bound[2], bool)):
return __class__.addStudent1(self, *bound)
raise TypeError("No method matches provided parameters")
def removeStudent(self, aStudent):
if aStudent.getTeacher() is self:
return False
index = next((i for i, x in enumerate(self._students) if x is aStudent), -1)
if index >= 0:
del self._students[index]
return True
def addStudentAt(self, aStudent, index):
if not self.addStudent2(aStudent):
return False
if index < 0:
index = 0
if index > self.numberOfStudents():
index = self.numberOfStudents() - 1
del self._students[next((i for i, x in enumerate(self._students) if x is aStudent), -1)]
self._students.insert(index, aStudent)
return True
def addOrMoveStudentAt(self, aStudent, index):
if not any(x is aStudent for x in self._students):
return self.addStudentAt(aStudent, index)
if index < 0:
index = 0
if index > self.numberOfStudents():
index = self.numberOfStudents() - 1
del self._students[next((i for i, x in enumerate(self._students) if x is aStudent), -1)]
self._students.insert(index, aStudent)
return True
def delete(self):
for i in range(len(self._students), 0, -1):
aStudent = self._students[i - 1]
aStudent.delete()
super().delete()
@staticmethod
def _bindArguments(names, varargs, args, kwargs):
if len(args) > len(names) and not varargs:
return None
bound = list(args[:len(names)])
for name in names[len(bound):]:
if name not in kwargs:
return None
bound.append(kwargs[name])
if len(kwargs) != len(names) - min(len(args), len(names)):
return None
if varargs:
bound.append(args[len(names):])
return bound
def __str__(self):
return (super().__str__() + "["
+ "position:" + str(self.getPosition())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
def __init__(self, aNumber):
self._number = aNumber
self._canSetNumber2 = True
self._number2 = None
def setNumber2(self, aNumber2):
if not self._canSetNumber2:
return False
self._canSetNumber2 = False
self._number2 = aNumber2
return True
def getNumber(self):
return self._number
def getNumber2(self):
return self._number2
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "number:" + str(self.getNumber()) + ","
+ "number2:" + str(self.getNumber2())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
a = ""
def __init__(self, aB):
self._b = aB
def getC(self):
"""Comment for a derived attribute"""
return 1 + 1
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "c:" + str(self.getC())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
"""
This is a student
Multiple comments
on several lines
"""
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Foo:
def __init__(self):
self._bars = []
def getBar(self, index):
return self._bars[index]
def getBars(self):
"""I am a inline comment above an association."""
return tuple(self._bars)
def numberOfBars(self):
return len(self._bars)
def hasBars(self):
return len(self._bars) > 0
def indexOfBar(self, aBar):
return next((i for i, x in enumerate(self._bars) if x is aBar), -1)
@staticmethod
def minimumNumberOfBars():
return 0
def addBar1(self):
from Bar import Bar
return Bar(self)
def addBar2(self, aBar):
if any(x is aBar for x in self._bars):
return False
existingFoo = aBar.getFoo()
isNewFoo = existingFoo is not None and existingFoo is not self
if isNewFoo:
if not aBar.setFoo(self):
return False
else:
self._bars.append(aBar)
return True
def addBar(self, *args, **kwargs):
from Bar import Bar
bound = __class__._bindArguments(("aBar",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Bar)):
return __class__.addBar2(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.addBar1(self, *bound)
raise TypeError("No method matches provided parameters")
def removeBar(self, aBar):
if aBar.getFoo() is self:
return False
index = next((i for i, x in enumerate(self._bars) if x is aBar), -1)
if index >= 0:
del self._bars[index]
return True
def addBarAt(self, aBar, index):
if not self.addBar2(aBar):
return False
if index < 0:
index = 0
if index > self.numberOfBars():
index = self.numberOfBars() - 1
del self._bars[next((i for i, x in enumerate(self._bars) if x is aBar), -1)]
self._bars.insert(index, aBar)
return True
def addOrMoveBarAt(self, aBar, index):
if not any(x is aBar for x in self._bars):
return self.addBarAt(aBar, index)
if index < 0:
index = 0
if index > self.numberOfBars():
index = self.numberOfBars() - 1
del self._bars[next((i for i, x in enumerate(self._bars) if x is aBar), -1)]
self._bars.insert(index, aBar)
return True
def delete(self):
for i in range(len(self._bars), 0, -1):
aBar = self._bars[i - 1]
aBar.delete()
@staticmethod
def _bindArguments(names, varargs, args, kwargs):
if len(args) > len(names) and not varargs:
return None
bound = list(args[:len(names)])
for name in names[len(bound):]:
if name not in kwargs:
return None
bound.append(kwargs[name])
if len(kwargs) != len(names) - min(len(args), len(names)):
return None
if varargs:
bound.append(args[len(names):])
return bound
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Student:
"""This is a student"""
def __init__(self):
pass
def delete(self):
pass
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Foo:
def __init__(self):
self._bar1s = []
self._bar2s = []
self._bar3s = []
self._bar4s = []
def getBar1(self, index):
return self._bar1s[index]
def getBar1s(self):
"""Inline comment above association."""
return tuple(self._bar1s)
def numberOfBar1s(self):
return len(self._bar1s)
def hasBar1s(self):
return len(self._bar1s) > 0
def indexOfBar1(self, aBar1):
return next((i for i, x in enumerate(self._bar1s) if x is aBar1), -1)
def getBar2(self, index):
return self._bar2s[index]
def getBar2s(self):
"""
Multiple inline comments
above association.
"""
return tuple(self._bar2s)
def numberOfBar2s(self):
return len(self._bar2s)
def hasBar2s(self):
return len(self._bar2s) > 0
def indexOfBar2(self, aBar2):
return next((i for i, x in enumerate(self._bar2s) if x is aBar2), -1)
def getBar3(self, index):
return self._bar3s[index]
def getBar3s(self):
"""Multiline comment above association."""
return tuple(self._bar3s)
def numberOfBar3s(self):
return len(self._bar3s)
def hasBar3s(self):
return len(self._bar3s) > 0
def indexOfBar3(self, aBar3):
return next((i for i, x in enumerate(self._bar3s) if x is aBar3), -1)
def getBar4(self, index):
return self._bar4s[index]
def getBar4s(self):
"""
* Multiple multiline comments
* above association.
"""
return tuple(self._bar4s)
def numberOfBar4s(self):
return len(self._bar4s)
def hasBar4s(self):
return len(self._bar4s) > 0
def indexOfBar4(self, aBar4):
return next((i for i, x in enumerate(self._bar4s) if x is aBar4), -1)
@staticmethod
def minimumNumberOfBar1s():
return 0
def addBar11(self):
from Bar1 import Bar1
return Bar1(self)
def addBar12(self, aBar1):
if any(x is aBar1 for x in self._bar1s):
return False
existingFoo = aBar1.getFoo()
isNewFoo = existingFoo is not None and existingFoo is not self
if isNewFoo:
if not aBar1.setFoo(self):
return False
else:
self._bar1s.append(aBar1)
return True
def addBar1(self, *args, **kwargs):
from Bar1 import Bar1
bound = __class__._bindArguments(("aBar1",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Bar1)):
return __class__.addBar12(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.addBar11(self, *bound)
raise TypeError("No method matches provided parameters")
def removeBar1(self, aBar1):
if aBar1.getFoo() is self:
return False
index = next((i for i, x in enumerate(self._bar1s) if x is aBar1), -1)
if index >= 0:
del self._bar1s[index]
return True
def addBar1At(self, aBar1, index):
if not self.addBar12(aBar1):
return False
if index < 0:
index = 0
if index > self.numberOfBar1s():
index = self.numberOfBar1s() - 1
del self._bar1s[next((i for i, x in enumerate(self._bar1s) if x is aBar1), -1)]
self._bar1s.insert(index, aBar1)
return True
def addOrMoveBar1At(self, aBar1, index):
if not any(x is aBar1 for x in self._bar1s):
return self.addBar1At(aBar1, index)
if index < 0:
index = 0
if index > self.numberOfBar1s():
index = self.numberOfBar1s() - 1
del self._bar1s[next((i for i, x in enumerate(self._bar1s) if x is aBar1), -1)]
self._bar1s.insert(index, aBar1)
return True
@staticmethod
def minimumNumberOfBar2s():
return 0
def addBar21(self):
from Bar2 import Bar2
return Bar2(self)
def addBar22(self, aBar2):
if any(x is aBar2 for x in self._bar2s):
return False
existingFoo = aBar2.getFoo()
isNewFoo = existingFoo is not None and existingFoo is not self
if isNewFoo:
if not aBar2.setFoo(self):
return False
else:
self._bar2s.append(aBar2)
return True
def addBar2(self, *args, **kwargs):
from Bar2 import Bar2
bound = __class__._bindArguments(("aBar2",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Bar2)):
return __class__.addBar22(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.addBar21(self, *bound)
raise TypeError("No method matches provided parameters")
def removeBar2(self, aBar2):
if aBar2.getFoo() is self:
return False
index = next((i for i, x in enumerate(self._bar2s) if x is aBar2), -1)
if index >= 0:
del self._bar2s[index]
return True
def addBar2At(self, aBar2, index):
if not self.addBar22(aBar2):
return False
if index < 0:
index = 0
if index > self.numberOfBar2s():
index = self.numberOfBar2s() - 1
del self._bar2s[next((i for i, x in enumerate(self._bar2s) if x is aBar2), -1)]
self._bar2s.insert(index, aBar2)
return True
def addOrMoveBar2At(self, aBar2, index):
if not any(x is aBar2 for x in self._bar2s):
return self.addBar2At(aBar2, index)
if index < 0:
index = 0
if index > self.numberOfBar2s():
index = self.numberOfBar2s() - 1
del self._bar2s[next((i for i, x in enumerate(self._bar2s) if x is aBar2), -1)]
self._bar2s.insert(index, aBar2)
return True
@staticmethod
def minimumNumberOfBar3s():
return 0
def addBar31(self):
from Bar3 import Bar3
return Bar3(self)
def addBar32(self, aBar3):
if any(x is aBar3 for x in self._bar3s):
return False
existingFoo = aBar3.getFoo()
isNewFoo = existingFoo is not None and existingFoo is not self
if isNewFoo:
if not aBar3.setFoo(self):
return False
else:
self._bar3s.append(aBar3)
return True
def addBar3(self, *args, **kwargs):
from Bar3 import Bar3
bound = __class__._bindArguments(("aBar3",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Bar3)):
return __class__.addBar32(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.addBar31(self, *bound)
raise TypeError("No method matches provided parameters")
def removeBar3(self, aBar3):
if aBar3.getFoo() is self:
return False
index = next((i for i, x in enumerate(self._bar3s) if x is aBar3), -1)
if index >= 0:
del self._bar3s[index]
return True
def addBar3At(self, aBar3, index):
if not self.addBar32(aBar3):
return False
if index < 0:
index = 0
if index > self.numberOfBar3s():
index = self.numberOfBar3s() - 1
del self._bar3s[next((i for i, x in enumerate(self._bar3s) if x is aBar3), -1)]
self._bar3s.insert(index, aBar3)
return True
def addOrMoveBar3At(self, aBar3, index):
if not any(x is aBar3 for x in self._bar3s):
return self.addBar3At(aBar3, index)
if index < 0:
index = 0
if index > self.numberOfBar3s():
index = self.numberOfBar3s() - 1
del self._bar3s[next((i for i, x in enumerate(self._bar3s) if x is aBar3), -1)]
self._bar3s.insert(index, aBar3)
return True
@staticmethod
def minimumNumberOfBar4s():
return 0
def addBar41(self):
from Bar4 import Bar4
return Bar4(self)
def addBar42(self, aBar4):
if any(x is aBar4 for x in self._bar4s):
return False
existingFoo = aBar4.getFoo()
isNewFoo = existingFoo is not None and existingFoo is not self
if isNewFoo:
if not aBar4.setFoo(self):
return False
else:
self._bar4s.append(aBar4)
return True
def addBar4(self, *args, **kwargs):
from Bar4 import Bar4
bound = __class__._bindArguments(("aBar4",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Bar4)):
return __class__.addBar42(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.addBar41(self, *bound)
raise TypeError("No method matches provided parameters")
def removeBar4(self, aBar4):
if aBar4.getFoo() is self:
return False
index = next((i for i, x in enumerate(self._bar4s) if x is aBar4), -1)
if index >= 0:
del self._bar4s[index]
return True
def addBar4At(self, aBar4, index):
if not self.addBar42(aBar4):
return False
if index < 0:
index = 0
if index > self.numberOfBar4s():
index = self.numberOfBar4s() - 1
del self._bar4s[next((i for i, x in enumerate(self._bar4s) if x is aBar4), -1)]
self._bar4s.insert(index, aBar4)
return True
def addOrMoveBar4At(self, aBar4, index):
if not any(x is aBar4 for x in self._bar4s):
return self.addBar4At(aBar4, index)
if index < 0:
index = 0
if index > self.numberOfBar4s():
index = self.numberOfBar4s() - 1
del self._bar4s[next((i for i, x in enumerate(self._bar4s) if x is aBar4), -1)]
self._bar4s.insert(index, aBar4)
return True
def delete(self):
for i in range(len(self._bar1s), 0, -1):
aBar1 = self._bar1s[i - 1]
aBar1.delete()
for i in range(len(self._bar2s), 0, -1):
aBar2 = self._bar2s[i - 1]
aBar2.delete()
for i in range(len(self._bar3s), 0, -1):
aBar3 = self._bar3s[i - 1]
aBar3.delete()
for i in range(len(self._bar4s), 0, -1):
aBar4 = self._bar4s[i - 1]
aBar4.delete()
@staticmethod
def _bindArguments(names, varargs, args, kwargs):
if len(args) > len(names) and not varargs:
return None
bound = list(args[:len(names)])
for name in names[len(bound):]:
if name not in kwargs:
return None
bound.append(kwargs[name])
if len(kwargs) != len(names) - min(len(args), len(names)):
return None
if varargs:
bound.append(args[len(names):])
return bound
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Teacher:
def __init__(self):
self._myFooss = []
def getMyFooss1(self, index):
return self._myFooss[index]
def getMyFooss2(self):
return tuple(self._myFooss)
def getMyFooss(self, *args, **kwargs):
bound = __class__._bindArguments(("index",), False, args, kwargs)
if bound is not None and (isinstance(bound[0], int) and not isinstance(bound[0], bool)):
return __class__.getMyFooss1(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.getMyFooss2(self, *bound)
raise TypeError("No method matches provided parameters")
def numberOfMyFooss(self):
return len(self._myFooss)
def hasMyFooss(self):
return len(self._myFooss) > 0
def indexOfMyFooss(self, aMyFooss):
return next((i for i, x in enumerate(self._myFooss) if x is aMyFooss), -1)
@staticmethod
def minimumNumberOfMyFooss():
return 0
@staticmethod
def maximumNumberOfMyFooss():
return 2
def addMyFooss(self, aMyFooss):
if any(x is aMyFooss for x in self._myFooss):
return False
if self.numberOfMyFooss() >= self.maximumNumberOfMyFooss():
return False
existingTeacher = aMyFooss.getTeacher()
isNewTeacher = existingTeacher is not None and existingTeacher is not self
if isNewTeacher:
if not aMyFooss.setTeacher(self):
return False
else:
self._myFooss.append(aMyFooss)
return True
def removeMyFooss(self, aMyFooss):
if aMyFooss.getTeacher() is self:
return False
index = next((i for i, x in enumerate(self._myFooss) if x is aMyFooss), -1)
if index >= 0:
del self._myFooss[index]
return True
def addMyFoossAt(self, aMyFooss, index):
if not self.addMyFooss(aMyFooss):
return False
if index < 0:
index = 0
if index > self.numberOfMyFooss():
index = self.numberOfMyFooss() - 1
del self._myFooss[next((i for i, x in enumerate(self._myFooss) if x is aMyFooss), -1)]
self._myFooss.insert(index, aMyFooss)
return True
def addOrMoveMyFoossAt(self, aMyFooss, index):
if not any(x is aMyFooss for x in self._myFooss):
return self.addMyFoossAt(aMyFooss, index)
if index < 0:
index = 0
if index > self.numberOfMyFooss():
index = self.numberOfMyFooss() - 1
del self._myFooss[next((i for i, x in enumerate(self._myFooss) if x is aMyFooss), -1)]
self._myFooss.insert(index, aMyFooss)
return True
def delete(self):
for i in range(len(self._myFooss), 0, -1):
aMyFooss = self._myFooss[i - 1]
aMyFooss.delete()
@staticmethod
def _bindArguments(names, varargs, args, kwargs):
if len(args) > len(names) and not varargs:
return None
bound = list(args[:len(names)])
for name in names[len(bound):]:
if name not in kwargs:
return None
bound.append(kwargs[name])
if len(kwargs) != len(names) - min(len(args), len(names)):
return None
if varargs:
bound.append(args[len(names):])
return bound
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Foo:
def __init__(self, aBar):
self._bar = aBar
def setBar(self, aBar):
self._bar = aBar
return True
def getBar(self):
"""I am a inline comment above an attribute."""
return self._bar
def delete(self):
pass
def __str__(self):
return (super().__str__() + "["
+ "bar:" + str(self.getBar())
+ "]")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
class Mentor:
def __init__(self):
pass
def delete(self):
pass