|
楼主 |
发表于 2012-3-6 09:15:08
|
显示全部楼层
代码帖的有点乱,怎么都没人能帮忙看看呢? ; a# q, V8 \1 |1 r3 o7 h; L3 Q9 ?; F
public void spreadmoney(int m){6 w/ ?. W$ u1 X/ T# `+ |
for(int i=0;i<m;i++){ `0 y0 t, U2 f) q+ g* T: a
int x = (int)(Math.random()*(moneyspace.getSizeX()));
% C, W* S+ K4 q# ~ int y = (int)(Math.random()*(moneyspace.getSizeY()));3 t! f) [- k0 L" h+ |
! A0 |8 u! T& W, Q
int I;
: ?" u5 Q$ v, Z( g if(moneyspace.getObjectAt(x,y)!=null
7 I' l: |" e) ]) {& O8 x5 r I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();. O- g- \& }. h2 t, C
}2 D+ ~7 t' i# A, \4 C( J) l
else{# ?+ V$ H; m8 O% B- ^5 a6 e
I = 0;$ u# {9 ?8 W1 G: i% M
}
" T- ?8 q, S! t/ j moneyspace.putObjectAt(x, y, new Integer(I+1)); }
R& ^* Q2 G2 u; d+ _1 P* t } |
|