/
ImmutableUnidirectionalOneTest.ruby.txt
69 lines (55 loc) · 1.75 KB
/
ImmutableUnidirectionalOneTest.ruby.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# PLEASE DO NOT EDIT THIS CODE
# This code was generated using the UMPLE @UMPLE_VERSION@ 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 :number
#Student Associations - for documentation purposes
#attr_reader :mentor
#------------------------
# CONSTRUCTOR
#------------------------
def initialize(a_number, a_mentor)
@initialized = false
@deleted = false
@number = a_number
@can_set_number = false
@can_set_mentor = true
unless set_mentor(a_mentor)
raise "Unable to create Student due to a_mentor. See http://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"
end
@initialized = true
end
#------------------------
# INTERFACE
#------------------------
def get_number
raise "Mandatory relationship with mentor not satisfied" if (@initialized and !@deleted and @mentor.nil?)
@number
end
def get_mentor
raise "Mandatory relationship with mentor not satisfied" if (@initialized and !@deleted and @mentor.nil?)
@mentor
end
def set_mentor(a_new_mentor)
was_set = false
raise "Mandatory relationship with mentor not satisfied" if (@initialized and !@deleted and @mentor.nil?)
return false unless @can_set_mentor
@can_set_mentor = false
unless a_new_mentor.nil?
@mentor = a_new_mentor
was_set = true
end
was_set
end
def delete
@deleted = true
raise "Mandatory relationship with mentor not satisfied" if (@initialized and !@deleted and @mentor.nil?)
end
end
end