-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpet_test_no_ring.rb
145 lines (112 loc) · 3.22 KB
/
pet_test_no_ring.rb
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# -*- coding: utf-8 -*-
# test Pet
# 没有结婚戒指情况下的结婚测试。
require "./pet.rb"
xiao_zhang= Pet.new("张飞")
xiao_zhang.sex=0
xiao_zhang_wife= Pet.new("小龙女")
xiao_zhang_wife.sex=1
puts xiao_zhang.inspect
50.times{xiao_zhang.level_up}
puts xiao_zhang.inspect
puts ""
40.times{xiao_zhang_wife.level_up}
puts xiao_zhang_wife.inspect
puts ""
xiao_zhang_wife.level_up
if xiao_zhang.can_get_married?(xiao_zhang_wife) then
xiao_zhang.marriage(xiao_zhang_wife,ring=false)
puts "哇,结婚了!新伙伴诞生了!革命事业我来扛,一代更比一代强。"
else
puts "Not marriaged, god!"
end
puts xiao_zhang.inspect
puts ""
xiao_zhang_wife1= Pet.new("迎春")
if(xiao_zhang.sex==1) then
xiao_zhang_wife1.sex=0
else
xiao_zhang_wife1.sex=1
end
51.times{xiao_zhang.level_up}
40.times{xiao_zhang_wife1.level_up}
puts xiao_zhang_wife1.inspect
if xiao_zhang.can_get_married?(xiao_zhang_wife1) then
xiao_zhang.marriage(xiao_zhang_wife1,ring=false)
puts "哇,结婚了!新伙伴诞生了!革命事业我来扛,一代更比一代强。"
else
puts "Not marriaged, god!"
end
puts xiao_zhang.inspect
puts ""
# --------------------------------------------------------------------------------
xiao_zhang_wife2= Pet.new("黛玉")
if(xiao_zhang.sex==1) then
xiao_zhang_wife2.sex=0
else
xiao_zhang_wife2.sex=1
end
51.times{xiao_zhang.level_up}
40.times{xiao_zhang_wife2.level_up}
puts xiao_zhang_wife2.inspect
if xiao_zhang.can_get_married?(xiao_zhang_wife2) then
xiao_zhang.marriage(xiao_zhang_wife2,ring=false)
puts "哇,结婚了!新伙伴诞生了!革命事业我来扛,一代更比一代强。"
else
puts "Not marriaged, god!"
end
puts xiao_zhang.inspect
puts ""
# 结婚100次。
100.times{
# 先升级主将到50级别。
xiao_zhang.set_level(1)
loop do
if xiao_zhang.level >= 50
break
else
xiao_zhang.level_up
end
end
# 造一个副将。
xiao_zhang_wife2= Pet.new("黛玉")
# 先升级副将到40级。
40.times{xiao_zhang_wife2.level_up}
# 测试能否结婚。
if xiao_zhang.can_get_married?(xiao_zhang_wife2) then
xiao_zhang.marriage(xiao_zhang_wife2,ring=false)
puts "哇,结婚了!新伙伴诞生了!革命事业我来扛,一代更比一代强。"
else
puts "Not marriaged, god!"
end
puts xiao_zhang.inspect
puts ""
}
# 结婚500次。
500.times{
# 先升级主将到50级别。
xiao_zhang.set_level(1)
loop do
if xiao_zhang.level >= 50
break
else
xiao_zhang.level_up
end
end
# 造一个副将。
xiao_zhang_wife2= Pet.new("黛玉")
# 先升级副将到40级。
40.times{xiao_zhang_wife2.level_up}
# 测试能否结婚。
if xiao_zhang.can_get_married?(xiao_zhang_wife2) then
xiao_zhang.marriage(xiao_zhang_wife2,ring=false)
puts "哇,结婚了!新伙伴诞生了!革命事业我来扛,一代更比一代强。"
else
puts "Not marriaged, god!"
end
puts xiao_zhang.inspect
puts ""
}
xiao_zhang.write_version_star_record
puts "Done!"
# 上述代码验证,结婚系统及其支撑系统正确。