|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
w8 g6 U" z, D, M; w% A. Z) T public void spreadmoney(int m){8 t6 \- @4 i4 }
for(int i=0;i<m;i++){
1 f& J: h9 G; ]* W int x = (int)(Math.random()*(moneyspace.getSizeX()));
9 u, \% Z! U2 O# m/ M t int y = (int)(Math.random()*(moneyspace.getSizeY()));
- h; @% G% p: c6 v' e( j
' n! A# Q' y4 X% s int I;
/ n2 K6 b6 v; Z* V- P& i if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
* G# L8 |" d. [, i, D }
3 a/ @$ f1 Z) S3 W$ h else{
$ {0 \) `$ ^# Z6 c# }7 o I = 0;" a O& ^! E( ~- I% ?! D
}
) }0 k- r" B6 b moneyspace.putObjectAt(x, y, new Integer(I+1)); }/ k L$ x7 a5 _+ O. t3 A
} |
|