|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?) Z/ U0 x$ h2 e0 m' W0 J
public void spreadmoney(int m){0 |7 \0 X9 C8 T) x" _3 i! h( g
for(int i=0;i<m;i++){, P6 I; o8 N. O
int x = (int)(Math.random()*(moneyspace.getSizeX()));
4 Z# m/ h" e5 w7 G int y = (int)(Math.random()*(moneyspace.getSizeY()));
9 @5 i, u5 i- e3 V
! B8 v1 M4 {" B# h int I;' d3 |, w6 y' Q# S( H
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
, U8 {0 G5 U4 Y; ?0 ~ }" R& l/ W$ o; \0 P5 Z& k# F; R( }
else{0 u a, L3 v' p: Z
I = 0;
4 B0 t9 n0 F/ r5 c8 V3 B }
% p( V9 R$ |! c4 P; ` moneyspace.putObjectAt(x, y, new Integer(I+1)); }! |, X* m! V" H$ q. x; L
} |
|