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

module Example

class Student


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

  #Student Associations - for documentation purposes
  #attr_reader :mentors

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

  def initialize()
    @initialized = false
    @deleted = false
    @mentors = []
    @initialized = true
  end

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

  def get_mentor(index)
    a_mentor = @mentors[index]
    a_mentor
  end

  def get_mentors
    new_mentors = @mentors.dup
    new_mentors
  end

  def number_of_mentors
    number = @mentors.size
    number
  end

  def has_mentors
    has = @mentors.size > 0
    has
  end

  def index_of_mentor(a_mentor)
    index = @mentors.index(a_mentor)
    index = -1 if index.nil?
    index
  end

  def self.minimum_number_of_mentors
    0
  end

  def add_mentor(a_mentor)
    was_added = false
    return false if index_of_mentor(a_mentor) != -1
    @mentors << a_mentor
    if a_mentor.index_of_student(self) != -1
      was_added = true
    else
      was_added = a_mentor.add_student(self)
      unless was_added
        @mentors.delete(a_mentor)
      end
    end
    was_added
  end

  def remove_mentor(a_mentor)
    was_removed = false
    unless @mentors.include?(a_mentor)
      return was_removed
    end

    oldIndex = @mentors.index(a_mentor)
    @mentors.delete_at(oldIndex)
    if a_mentor.index_of_student(self) == -1
      was_removed = true
    else
      was_removed = a_mentor.remove_student(self)
      @mentors.insert(oldIndex,a_mentor) unless was_removed
    end
    was_removed
  end

  def add_mentor_at(a_mentor, index)
    was_added = false
    if add_mentor(a_mentor)
      if(index < 0)
        index = 0
      end
      if(index > number_of_mentors())
        index = number_of_mentors() - 1
      end
      @mentors.delete(a_mentor)
      @mentors.insert(index, a_mentor)
      was_added = true
    end
    was_added
  end

  def add_or_move_mentor_at(a_mentor, index)
    was_added = false
    if @mentors.include?(a_mentor)
      if(index < 0)
        index = 0
      end
      if(index > number_of_mentors())
        index = number_of_mentors() - 1
      end
      @mentors.delete(a_mentor)
      @mentors.insert(index, a_mentor)
      was_added = true
    else
      was_added = add_mentor_at(a_mentor, index)
    end
    was_added
  end

  def delete
    @deleted = true
    copy_of_mentors = @mentors.dup
    @mentors.clear
    copy_of_mentors.each do |a_mentor|
      a_mentor.remove_student(self)
    end
  end

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

module Example

class Student


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

  #Student Associations - for documentation purposes
  #attr_reader :mentors

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

  def initialize()
    @initialized = false
    @deleted = false
    @mentors = []
    @initialized = true
  end

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

  def get_mentor(index)
    a_mentor = @mentors[index]
    a_mentor
  end

  def get_mentors
    new_mentors = @mentors.dup
    new_mentors
  end

  def number_of_mentors
    number = @mentors.size
    number
  end

  def has_mentors
    has = @mentors.size > 0
    has
  end

  def index_of_mentor(a_mentor)
    index = @mentors.index(a_mentor)
    index = -1 if index.nil?
    index
  end

  def self.minimum_number_of_mentors
    0
  end

  def add_mentor(a_mentor)
    was_added = false
    return false if index_of_mentor(a_mentor) != -1
    @mentors << a_mentor
    if a_mentor.index_of_student(self) != -1
      was_added = true
    else
      was_added = a_mentor.add_student(self)
      unless was_added
        @mentors.delete(a_mentor)
      end
    end
    was_added
  end

  def remove_mentor(a_mentor)
    was_removed = false
    unless @mentors.include?(a_mentor)
      return was_removed
    end

    oldIndex = @mentors.index(a_mentor)
    @mentors.delete_at(oldIndex)
    if a_mentor.index_of_student(self) == -1
      was_removed = true
    else
      was_removed = a_mentor.remove_student(self)
      @mentors.insert(oldIndex,a_mentor) unless was_removed
    end
    was_removed
  end

  def add_mentor_at(a_mentor, index)
    was_added = false
    if add_mentor(a_mentor)
      if(index < 0)
        index = 0
      end
      if(index > number_of_mentors())
        index = number_of_mentors() - 1
      end
      @mentors.delete(a_mentor)
      @mentors.insert(index, a_mentor)
      was_added = true
    end
    was_added
  end

  def add_or_move_mentor_at(a_mentor, index)
    was_added = false
    if @mentors.include?(a_mentor)
      if(index < 0)
        index = 0
      end
      if(index > number_of_mentors())
        index = number_of_mentors() - 1
      end
      @mentors.delete(a_mentor)
      @mentors.insert(index, a_mentor)
      was_added = true
    else
      was_added = add_mentor_at(a_mentor, index)
    end
    was_added
  end

  def delete
    @deleted = true
    copy_of_mentors = @mentors.dup
    @mentors.clear
    copy_of_mentors.each do |a_mentor|
      a_mentor.remove_student(self)
    end
  end

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

module Example

class Student


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

  #Student Attributes - for documentation purposes
  #attr_reader :intId, :doubleId, :booleanId, :stringId, :stringListIds

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

  def initialize(a_intId, a_doubleId, a_booleanId, a_stringId)
    @initialized = false
    @deleted = false
    @cachedHashCode = -1
    @can_set_intId = true
    @can_set_doubleId = true
    @can_set_booleanId = true
    @can_set_stringId = true
    @can_set_stringListIds = true
    @intId = a_intId
    @doubleId = a_doubleId
    @booleanId = a_booleanId
    @stringId = a_stringId
    @stringListIds = []
    @initialized = true
  end

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

  def set_intId(a_intId)
    was_set = false
    return false unless @can_set_intId
    @intId = a_intId
    was_set = true
    was_set
  end

  def set_doubleId(a_doubleId)
    was_set = false
    return false unless @can_set_doubleId
    @doubleId = a_doubleId
    was_set = true
    was_set
  end

  def set_booleanId(a_booleanId)
    was_set = false
    return false unless @can_set_booleanId
    @booleanId = a_booleanId
    was_set = true
    was_set
  end

  def set_stringId(a_stringId)
    was_set = false
    return false unless @can_set_stringId
    @stringId = a_stringId
    was_set = true
    was_set
  end

  def add_stringListId(a_stringListId)
    was_added = false
    return false unless @can_set_stringListIds
    was_added = stringListIds << a_stringListId
    was_added
  end

  def remove_stringListId(a_stringListId)
    was_removed = false
    return false unless @can_set_stringListIds
    was_removed = stringListIds.delete(a_stringListId)
    was_removed
  end

  def get_intId
    @intId
  end

  def get_doubleId
    @doubleId
  end

  def get_booleanId
    @booleanId
  end

  def get_stringId
    @stringId
  end

  def get_stringListId(index)
    a_stringListId = stringListIds[index]
    a_stringListId
  end

  def get_stringListIds
    String[] new_stringListIds = stringListIds.toArray(new String[stringListIds.size])
    new_stringListIds
  end

  def number_of_stringListIds
    number = stringListIds.size
    number;
  end

  def has_stringListIds
    has = stringListIds.size > 0
    has
  end

  def index_of_stringListId(a_stringListId)
    index = stringListIds.index(a_stringListId)
    index = -1 if index.nil?
    index
  end

  def is_booleanId?
    @booleanId
  end

  def eql?(obj)
    return false if obj.nil?
    return false unless self.class == obj.class

    compareTo = obj
    return false unless @intId == compareTo.instance_variable_get("@intId")

    return false unless @doubleId == compareTo.instance_variable_get("@doubleId")

    return false unless @booleanId == compareTo.instance_variable_get("@booleanId")

    return false if (@stringId.nil? and !compareTo.instance_variable_get("@stringId").nil?)
    return false if (!@stringId.nil? and !@stringId.eql?(compareTo.instance_variable_get("@stringId")))

    return false unless @stringListIds.size == compareTo.instance_variable_get("@stringListIds").size
    @stringListIds.each do |me|
      them = compareTo.instance_variable_get("@stringListIds").get(i)
      return false if (me.nil? and !them.nil?)
      return false if (!me.nil? and !me.eql?(them))
    end
    true
  end

  def hash
    return @cachedHashCode unless @cachedHashCode == -1
    @cachedHashCode = 17
    @cachedHashCode = @cachedHashCode * 23 + @intId

    @cachedHashCode = @cachedHashCode * 23 + @doubleId.hash

    @cachedHashCode = @cachedHashCode * 23 + (@booleanId ? 1 : 0)

    if (!@stringId.nil?)
      @cachedHashCode = @cachedHashCode * 23 + @stringId.hash
    else
      @cachedHashCode = @cachedHashCode * 23
    end

    if (!@stringListIds.nil?)
      @cachedHashCode = @cachedHashCode * 23 + @stringListIds.hash
    else
      @cachedHashCode = @cachedHashCode * 23
    end
    @can_set_intId = false
    @can_set_doubleId = false
    @can_set_booleanId = false
    @can_set_stringId = false
    @can_set_stringListIds = false
    @cachedHashCode
  end

  def delete
    @deleted = true
  end

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

module Example

class Student


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

  #Student Attributes - for documentation purposes
  #attr_reader :intId, :doubleId, :booleanId, :stringId

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

  def initialize(a_doubleId, a_booleanId, a_stringId)
    @initialized = false
    @deleted = false
    @cachedHashCode = -1
    @intId = 0
    @can_set_intId = true
    @doubleId = a_doubleId
    @can_set_doubleId = false
    @booleanId = a_booleanId
    @can_set_booleanId = false
    @stringId = a_stringId
    @can_set_stringId = false
    @initialized = true
  end

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

  def set_intId(a_intId)
    was_set = false
    return false unless @can_set_intId
    @can_set_intId = false
    @intId = a_intId
    was_set = true
    was_set
  end

  def get_intId
    @intId
  end

  def get_doubleId
    @doubleId
  end

  def get_booleanId
    @booleanId
  end

  def get_stringId
    @stringId
  end

  def is_booleanId?
    @booleanId
  end

  def eql?(obj)
    return false if obj.nil?
    return false unless self.class == obj.class

    compareTo = obj
    return false unless @intId == compareTo.instance_variable_get("@intId")

    return false unless @doubleId == compareTo.instance_variable_get("@doubleId")

    return false unless @booleanId == compareTo.instance_variable_get("@booleanId")

    return false if (@stringId.nil? and !compareTo.instance_variable_get("@stringId").nil?)
    return false if (!@stringId.nil? and !@stringId.eql?(compareTo.instance_variable_get("@stringId")))
    true
  end

  def hash
    return @cachedHashCode unless @cachedHashCode == -1
    @cachedHashCode = 17
    @cachedHashCode = @cachedHashCode * 23 + @intId

    @cachedHashCode = @cachedHashCode * 23 + @doubleId.hash

    @cachedHashCode = @cachedHashCode * 23 + (@booleanId ? 1 : 0)

    if (!@stringId.nil?)
      @cachedHashCode = @cachedHashCode * 23 + @stringId.hash
    else
      @cachedHashCode = @cachedHashCode * 23
    end
    @can_set_intId = false
    @can_set_doubleId = false
    @can_set_booleanId = false
    @can_set_stringId = false
    @cachedHashCode
  end

  def delete
    @deleted = true
  end

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

module Example

class Mentor


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

  #Mentor Associations - for documentation purposes
  #attr_reader :main, :secondaries

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

  def initialize()
    @initialized = false
    @deleted = false
    @cachedHashCode = -1
    @can_set_main = true
    @can_set_secondaries = true
    @main = nil
    @secondaries = []
    @initialized = true
  end

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

  def get_main
    @main
  end

  def has_main
    has = !@main.nil?
    has
  end

  def get_secondary(index)
    a_secondary = @secondaries[index]
    a_secondary
  end

  def get_secondaries
    new_secondaries = @secondaries.dup
    new_secondaries
  end

  def number_of_secondaries
    number = @secondaries.size
    number
  end

  def has_secondaries
    has = @secondaries.size > 0
    has
  end

  def index_of_secondary(a_secondary)
    index = @secondaries.index(a_secondary)
    index = -1 if index.nil?
    index
  end

  def set_main(a_new_main)
    was_set = false
    return false unless @can_set_main
    if a_new_main.nil?
      existing_main = @main
      @main = nil
      
      if !existing_main.nil? and !existing_main.get_mentorMain.nil?
        existing_main.set_mentorMain(nil)
      end
      was_set = true
      return was_set
    end

    current_main = self.get_main
    if !current_main.nil? and !current_main.eql?(a_new_main)
      current_main.set_mentorMain(nil)
    end

    @main = a_new_main
    existing_mentorMain = a_new_main.get_mentorMain

    unless self.eql?(existing_mentorMain)
      a_new_main.set_mentorMain(self)
    end
    was_set = true
    was_set
  end

  def self.minimum_number_of_secondaries
    0
  end

  def add_secondary(a_secondary)
    was_added = false
    return false unless @can_set_secondaries
    return false if index_of_secondary(a_secondary) != -1
    existing_mentorSecondary = a_secondary.get_mentorSecondary
    if existing_mentorSecondary.nil?
      a_secondary.set_mentorSecondary(self)
    elsif !existing_mentorSecondary.eql?(self)
      existing_mentorSecondary.remove_secondary(a_secondary)
      add_secondary(a_secondary)
    else
      @secondaries << a_secondary
    end
    was_added = true
    was_added
  end

  def remove_secondary(a_secondary)
    was_removed = false
    return false unless @can_set_secondaries
    if @secondaries.include?(a_secondary)
      @secondaries.delete(a_secondary)
      a_secondary.set_mentorSecondary(nil)
      was_removed = true
    end
    was_removed
  end

  def add_secondary_at(a_secondary, index)
    was_added = false
    if add_secondary(a_secondary)
      if(index < 0)
        index = 0
      end
      if(index > number_of_secondaries())
        index = number_of_secondaries() - 1
      end
      @secondaries.delete(a_secondary)
      @secondaries.insert(index, a_secondary)
      was_added = true
    end
    was_added
  end

  def add_or_move_secondary_at(a_secondary, index)
    was_added = false
    if @secondaries.include?(a_secondary)
      if(index < 0)
        index = 0
      end
      if(index > number_of_secondaries())
        index = number_of_secondaries() - 1
      end
      @secondaries.delete(a_secondary)
      @secondaries.insert(index, a_secondary)
      was_added = true
    else
      was_added = add_secondary_at(a_secondary, index)
    end
    was_added
  end

  def eql?(obj)
    return false if obj.nil?
    return false unless self.class == obj.class

    compareTo = obj
    return false if (@main.nil? and !compareTo.instance_variable_get("@main").nil?)
    return false if (!@main.nil? and !@main.eql?(compareTo.instance_variable_get("@main")))

    return false unless @secondaries.size == compareTo.instance_variable_get("@secondaries").size
    @secondaries.each do |me|
      them = compareTo.instance_variable_get("@secondaries").get(i)
      return false if (me.nil? and !them.nil?)
      return false if (!me.nil? and !me.eql?(them))
    end
    true
  end

  def hash
    return @cachedHashCode unless @cachedHashCode == -1
    @cachedHashCode = 17
    if (!@main.nil?)
      @cachedHashCode = @cachedHashCode * 23 + @main.hash
    else
      @cachedHashCode = @cachedHashCode * 23
    end
    if (!@secondaries.nil?)
      @cachedHashCode = @cachedHashCode * 23 + @secondaries.hash
    else
      @cachedHashCode = @cachedHashCode * 23
    end
    @can_set_main = false
    @can_set_secondaries = false
    @cachedHashCode
  end

  def delete
    @deleted = true
    unless @main.nil?
      @main.set_mentorMain(nil)
    end
    @secondaries.each do |a_secondary|
      a_secondary.set_mentorSecondary(nil)
    end
  end

end
end