|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?5 m1 _ ~* ^! z- u2 C* V+ N: K# Q
public void spreadmoney(int m){
+ c1 u- [* r! [+ {0 w for(int i=0;i<m;i++){
5 W8 r' b' Q) Z/ a4 C, T. n int x = (int)(Math.random()*(moneyspace.getSizeX()));
! S. ?5 E8 d, i6 X& ^# Q5 C+ K int y = (int)(Math.random()*(moneyspace.getSizeY()));' z) A9 ~9 {0 D+ P
$ c, w# S; Z1 j4 G' Z, h/ X% T int I;
3 b5 [9 a$ s0 j+ V9 C( ^: { if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();3 H1 E( ~ C+ S. Y' N! o. x. q0 o" e
}
# G5 h h' v1 j6 I5 [. i0 B else{7 d4 O" `2 D- p$ p
I = 0;( Y: ~9 o; x' F
}
( `' ]8 {% e. I6 m% M% q- U moneyspace.putObjectAt(x, y, new Integer(I+1)); }
2 G# z4 R) y# Z6 f; J7 P } |
|