|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?" K$ ?, a9 t! z& y! }
public void spreadmoney(int m){! b5 g0 Z- q3 w+ }1 H1 e
for(int i=0;i<m;i++){# T! l8 R; M( z& t! W: y3 \
int x = (int)(Math.random()*(moneyspace.getSizeX()));% t) B/ f5 z+ l% ]( W7 Y$ j# D
int y = (int)(Math.random()*(moneyspace.getSizeY()));3 [5 H. G) C5 \7 O7 U, ~; D
" f: n: x. |; M& \ int I;# z+ t, c( I) D
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();: C/ \/ \$ L% ?2 m/ h! K) m' ]1 }
}5 J8 V/ ~) m: L+ }' L0 U
else{, d5 o3 Y% I) ] u l
I = 0;
0 c: K8 V& Y" {+ s9 Q, y }, z7 x3 r; m0 P% v; R& S8 k
moneyspace.putObjectAt(x, y, new Integer(I+1)); }6 j% h* I' c6 D/ D8 [
} |
|