# PLEASE DO NOT EDIT THIS CODE
# This code was generated using the UMPLE 1.31.1.5860.78bb27cc6 modeling language!
# NOTE: Ruby generator is experimental and is missing some features available in
# in other Umple generated languages like Java or PHP



class Student


  #------------------------
  # MEMBER VARIABLES
  #------------------------

  #Student Attributes - for documentation purposes
  #attr_reader :id, :ProfsPriority

  #Student Associations - for documentation purposes
  #attr_reader :Profs

  #------------------------
  # CONSTRUCTOR
  #------------------------

  def initialize(a_id)
    @initialized = false
    @deleted = false
    @id = a_id
    @ProfsPriority = ""
    @Profs = []
    @initialized = true
  end

  #------------------------
  # INTERFACE
  #------------------------

  def set_id(a_id)
    was_set = false
    @id = a_id
    was_set = true
    was_set
  end

  def set_ProfsPriority(a_ProfsPriority)
    was_set = false
    @ProfsPriority = a_ProfsPriority
    was_set = true
    was_set
  end

  def get_id
    @id
  end

  def get_ProfsPriority
    @ProfsPriority
  end

  def get_Prof(index)
    a_Prof = @Profs[index]
    a_Prof
  end

  def get_Profs
    new_Profs = @Profs.dup
    new_Profs
  end

  def number_of_Profs
    number = @Profs.size
    number
  end

  def has_Profs
    has = @Profs.size > 0
    has
  end

  def index_of_Prof(a_Prof)
    index = @Profs.index(a_Prof)
    index = -1 if index.nil?
    index
  end

  def self.minimum_number_of_Profs
    0
  end

  def add_Prof(a_Prof)
    was_added = false
    return false if index_of_Prof(a_Prof) != -1
    @Profs << a_Prof
    if a_Prof.index_of_myStudent(self) != -1
      was_added = true
    else
      was_added = a_Prof.add_myStudent(self)
      unless was_added
        @Profs.delete(a_Prof)
      end
    end
    @Profs.sort! { |x, y| x.get_name() <=> y.get_name()} if wasAdded
    
    was_added
  end

  def remove_Prof(a_Prof)
    was_removed = false
    unless @Profs.include?(a_Prof)
      return was_removed
    end

    oldIndex = @Profs.index(a_Prof)
    @Profs.delete_at(oldIndex)
    if a_Prof.index_of_myStudent(self) == -1
      was_removed = true
    else
      was_removed = a_Prof.remove_myStudent(self)
      @Profs.insert(oldIndex,a_Prof) unless was_removed
    end
    was_removed
  end


  def delete
    @deleted = true
    copy_of_Profs = @Profs.dup
    @Profs.clear
    copy_of_Profs.each do |a_Prof|
      a_Prof.remove_myStudent(self)
    end
  end

end

# PLEASE DO NOT EDIT THIS CODE
# This code was generated using the UMPLE 1.31.1.5860.78bb27cc6 modeling language!
# NOTE: Ruby generator is experimental and is missing some features available in
# in other Umple generated languages like Java or PHP



class Mentor


  #------------------------
  # MEMBER VARIABLES
  #------------------------

  #Mentor Attributes - for documentation purposes
  #attr_reader :name, :myStudentsPriority

  #Mentor Associations - for documentation purposes
  #attr_reader :myStudents

  #------------------------
  # CONSTRUCTOR
  #------------------------

  def initialize(a_name)
    @initialized = false
    @deleted = false
    @name = a_name
    @myStudentsPriority = ""
    @myStudents = []
    @initialized = true
  end

  #------------------------
  # INTERFACE
  #------------------------

  def set_name(a_name)
    was_set = false
    @name = a_name
    was_set = true
    was_set
  end

  def set_myStudentsPriority(a_myStudentsPriority)
    was_set = false
    @myStudentsPriority = a_myStudentsPriority
    was_set = true
    was_set
  end

  def get_name
    @name
  end

  def get_myStudentsPriority
    @myStudentsPriority
  end

  def get_myStudent(index)
    a_myStudent = @myStudents[index]
    a_myStudent
  end

  def get_myStudents
    new_myStudents = @myStudents.dup
    new_myStudents
  end

  def number_of_myStudents
    number = @myStudents.size
    number
  end

  def has_myStudents
    has = @myStudents.size > 0
    has
  end

  def index_of_myStudent(a_myStudent)
    index = @myStudents.index(a_myStudent)
    index = -1 if index.nil?
    index
  end

  def self.minimum_number_of_myStudents
    0
  end

  def add_myStudent(a_myStudent)
    was_added = false
    return false if index_of_myStudent(a_myStudent) != -1
    @myStudents << a_myStudent
    if a_myStudent.index_of_Prof(self) != -1
      was_added = true
    else
      was_added = a_myStudent.add_Prof(self)
      unless was_added
        @myStudents.delete(a_myStudent)
      end
    end
    @myStudents.sort! { |x, y| x.get_id() <=> y.get_id()} if wasAdded
    
    was_added
  end

  def remove_myStudent(a_myStudent)
    was_removed = false
    unless @myStudents.include?(a_myStudent)
      return was_removed
    end

    oldIndex = @myStudents.index(a_myStudent)
    @myStudents.delete_at(oldIndex)
    if a_myStudent.index_of_Prof(self) == -1
      was_removed = true
    else
      was_removed = a_myStudent.remove_Prof(self)
      @myStudents.insert(oldIndex,a_myStudent) unless was_removed
    end
    was_removed
  end


  def delete
    @deleted = true
    copy_of_myStudents = @myStudents.dup
    @myStudents.clear
    copy_of_myStudents.each do |a_myStudent|
      a_myStudent.remove_Prof(self)
    end
  end

end