|
楼主 |
发表于 2012-3-6 09:15:08
|
显示全部楼层
代码帖的有点乱,怎么都没人能帮忙看看呢? / `' ]! y* x0 j. T- j! P
public void spreadmoney(int m){+ L' s0 J; R b% Y3 c! Q
for(int i=0;i<m;i++){
- U" n! ~2 Q6 a* ~; l2 u* \* J int x = (int)(Math.random()*(moneyspace.getSizeX()));
. ^6 X" D' L/ q. e0 p0 _+ O int y = (int)(Math.random()*(moneyspace.getSizeY()));: s- K( F9 I) L5 r6 ]' `. P* p
% A8 e8 v: ?, L! q( H+ h
int I;6 I0 X3 g: Z6 H" @' I
if(moneyspace.getObjectAt(x,y)!=null
- G6 D+ T/ v+ C$ Z9 Y% r+ F I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();& f& @; D7 i Z0 p* a+ V2 |. ~3 l
}
* b8 _# ^* j+ d# p3 g' s; D6 Y+ j else{
$ I* D( S, o% e1 q: T$ D7 ~! J0 h I = 0;8 F+ _7 r- p' r, {% g
}6 P$ h9 S! M/ D( Q- O& @ S) x
moneyspace.putObjectAt(x, y, new Integer(I+1)); }2 F# i# X0 K. W, L# h' j. E# u
} |
|