File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,15 @@ public void Fishing()
1414 {
1515 Console . WriteLine ( "开始下钩!" ) ;
1616
17- //用随机数模拟鱼咬钩,若随机数大于5,通知订阅者
18- var a = new Random ( 10 ) . Next ( ) ;
19- var type = ( FishType ) new Random ( ) . Next ( 0 , 5 ) ;
20- Console . WriteLine ( "铃铛:叮叮叮,鱼儿咬钩了" ) ;
21- if ( FishingEvent != null )
22- FishingEvent ( type ) ;
17+ //用随机数模拟鱼咬钩,若随机数为偶数,则为鱼咬钩
18+ if ( new Random ( ) . Next ( ) % 2 == 0 )
19+ {
20+ var a = new Random ( 10 ) . Next ( ) ;
21+ var type = ( FishType ) new Random ( ) . Next ( 0 , 5 ) ;
22+ Console . WriteLine ( "铃铛:叮叮叮,鱼儿咬钩了" ) ;
23+ if ( FishingEvent != null )
24+ FishingEvent ( type ) ;
25+ }
2326 }
2427 }
2528
Original file line number Diff line number Diff line change @@ -44,10 +44,13 @@ public void Fishing()
4444 {
4545 Console . WriteLine ( "开始下钩!" ) ;
4646
47- //用随机数模拟鱼咬钩,若随机数大于5,通知订阅者
48- var type = ( FishType ) new Random ( ) . Next ( 0 , 5 ) ;
49- Console . WriteLine ( "铃铛:叮叮叮,鱼儿咬钩了" ) ;
50- Notify ( type ) ;
47+ //用随机数模拟鱼咬钩,若随机数为偶数,则为鱼咬钩
48+ if ( new Random ( ) . Next ( ) % 2 == 0 )
49+ {
50+ var type = ( FishType ) new Random ( ) . Next ( 0 , 5 ) ;
51+ Console . WriteLine ( "铃铛:叮叮叮,鱼儿咬钩了" ) ;
52+ Notify ( type ) ;
53+ }
5154 }
5255 }
5356
You can’t perform that action at this time.
0 commit comments