#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!
# line 3 "../OptionalOneToOptionalOneTest.ump"

class Mentor():
    #------------------------
    # MEMBER VARIABLES
    #------------------------
    #Mentor Associations
    #------------------------
    # CONSTRUCTOR
    #------------------------
    def __init__(self):
        self._student = None

    #------------------------
    # INTERFACE
    #------------------------
    # Code from template association_GetOne 
    def getStudent(self):
        return self._student

    def hasStudent(self):
        has = not (self._student is None)
        return has

    # Code from template association_SetOptionalOneToOptionalOne 
    def setStudent(self, aNewStudent):
        wasSet = False
        if aNewStudent is None :
            existingStudent = self._student
            self._student = None
            if not (existingStudent is None) and not (existingStudent.getMentor() is None) :
                existingStudent.setMentor(None)
            wasSet = True
            return wasSet
        currentStudent = self.getStudent()
        if not (currentStudent is None) and not currentStudent == aNewStudent :
            currentStudent.setMentor(None)
        self._student = aNewStudent
        existingMentor = aNewStudent.getMentor()
        if not self == existingMentor :
            aNewStudent.setMentor(self)
        wasSet = True
        return wasSet

    def delete(self):
        if not (self._student is None) :
            self._student.setMentor(None)


#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!
# line 8 "../OptionalOneToOptionalOneTest.ump"

class Student():
    #------------------------
    # MEMBER VARIABLES
    #------------------------
    #Student Associations
    #------------------------
    # CONSTRUCTOR
    #------------------------
    def __init__(self):
        self._mentor = None

    #------------------------
    # INTERFACE
    #------------------------
    # Code from template association_GetOne 
    def getMentor(self):
        return self._mentor

    def hasMentor(self):
        has = not (self._mentor is None)
        return has

    # Code from template association_SetOptionalOneToOptionalOne 
    def setMentor(self, aNewMentor):
        wasSet = False
        if aNewMentor is None :
            existingMentor = self._mentor
            self._mentor = None
            if not (existingMentor is None) and not (existingMentor.getStudent() is None) :
                existingMentor.setStudent(None)
            wasSet = True
            return wasSet
        currentMentor = self.getMentor()
        if not (currentMentor is None) and not currentMentor == aNewMentor :
            currentMentor.setStudent(None)
        self._mentor = aNewMentor
        existingStudent = aNewMentor.getStudent()
        if not self == existingStudent :
            aNewMentor.setStudent(self)
        wasSet = True
        return wasSet

    def delete(self):
        if not (self._mentor is None) :
            self._mentor.setStudent(None)