| 赞 | 1 |
| VIP | 171 |
| 好人卡 | 21 |
| 积分 | 4 |
| 经验 | 59678 |
| 最后登录 | 2015-5-11 |
| 在线时间 | 1291 小时 |
- 梦石
- 0
- 星屑
- 362
- 在线时间
- 1291 小时
- 注册时间
- 2013-1-12
- 帖子
- 3590

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
只能說這一句話- class Feed
4 i& G( G+ C# |$ L - def initialize(type, like, dislike)
9 X4 `# d1 c- w0 g* Q' c - @like_type = like! t R. `( Z5 O' h2 J) W7 P& ]( W. s
- @dislike_type = dislike
" V/ F1 _/ J( }: h2 N - @type = type
6 W( K2 @* l0 g! l - start% K* n+ P8 z: |5 D" U( x
- end
* h' ~/ G8 ^$ [* m4 D8 `( c3 O. W - def start
, f7 g( N8 I- T$ ~' K! f - case @type/ Z! K& e- I& D+ w& B# }
- when 1 #Waters
: J+ f0 l/ Q1 ^+ }: x, }# b) J' W6 A - p "成長值增加了#{rand(3)+1},積分增加了#{rand(3)+1}"
G) O, I9 q1 x* F+ |2 l+ n2 ? - when 2 #Fruits6 ^# ]: c/ d8 g O
- a = 2 if @like_type = 2
% n o- k) v( W3 p/ \/ _ - a = -2 if @dislike_type = 2
' }9 Y# b f2 }: V3 } - p "成長值增加了#{rand(5)+a},積分增加了-1": h3 C$ [8 o$ L; }) a, K
- when 3 #Insects
u* g! \4 F! U x( }$ `3 i, t" | - a = 3 if @like_type = 3$ Y% o% q0 q ~2 a1 R% @9 G
- a = -3 if @dislike_type = 3; F$ d; Q( K' ], J& c
- p "成長值增加了#{rand(6)+a},積分增加了-1"
! T- G/ r( R# t& M - when 4 ; p* J+ q/ \( V. \4 s
- a = 3 if @like_type = 3
. `$ k& Q; ^4 g1 ]0 @: V8 I( [ - a = -3 if @dislike_type = 3# d& {1 X- d1 @* v
- p "成長值增加了#{rand(8)+a},積分增加了-2") R7 |* B+ p* H# m6 k+ N& P
- end
?; `: M) P5 ~) G. U - end
# g* X& X+ v, ]/ Q7 w! V - end
复制代码 調用方法:- Feed.new(feeding type, like type, dislike type)
复制代码 feeding type(喂食種類) 有四種選擇:
H- Y2 `, ]/ w1 I5 _5 U3 u i+ O* i1.水
- i: q; {9 o( q7 Y3 A7 [# r2.果子 y: o8 x7 k& r. _! L
3.昆蟲; B' Z+ p+ r5 \0 [! g* @
4.肉/ }7 Z% f3 V3 h! _' X5 @( w
like type(喜歡種類) 有三種選擇:
" q a7 @0 T6 w! T' ~5 Z- }7 m1.果子& d* P) i& y( [$ }2 B1 r
2.昆蟲
( a4 {$ T- A) D/ {! L6 T3.肉8 U9 I! }" M7 G
dislike type(不喜歡種類) 有三種選擇:
; c/ b( J% d8 z( x; l4 t8 i1.果子
, X- Q) @& X- s3 |& H2 J: U. Q2.昆蟲2 S; x4 x4 X0 m. y4 m$ S4 F: T
3.肉
7 g- W: m( x/ l8 k7 t7 J+ a例子:代表喂了水5 T8 G1 U# ?& g( Y' W& l
然後喂食者喜歡昆蟲 不喜歡肉 |
|