|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?+ D$ k/ o3 V+ R8 ?/ h
public void spreadmoney(int m){
% [- Z2 |+ O e- r0 B% m for(int i=0;i<m;i++){1 G: @6 ?+ x/ B% {; { y
int x = (int)(Math.random()*(moneyspace.getSizeX()));2 G: }3 @% ]; C
int y = (int)(Math.random()*(moneyspace.getSizeY()));# r( Y& _: S. V+ F7 S5 B9 R
2 B' G4 u9 w2 K/ Y7 D; D( B# x! W T! C
int I;
! Y7 x- b6 C# X t if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();. E9 ~' B h6 r3 m3 y+ G
}) N8 \* c* \, n8 h5 K
else{
7 N0 V, Z+ d0 N6 @. W8 K- I I = 0;
4 K1 A: `/ B! t! I) p$ Z }$ C m, S5 w, u+ i. ?* h
moneyspace.putObjectAt(x, y, new Integer(I+1)); }# d# c4 G# a$ D; W8 A
} |
|