private static int startx=40;
private static int starty=40;
private static int cols=9;
private static int rows=10;
private static int width;
private static int height;
private static  final int chesmamcount=16;

private static String[] strchesmanone={"車","馬","相","仕","将","仕","相","馬","車","炮","炮","卒","卒","卒","卒","卒"};
private static String[] strchesmantwo={"兵","兵","兵","兵","兵","炮","炮","车","马","象","士","帅","士","象","马","车"};
private static Hashtable<Rectangle, String> htone=new Hashtable<Rectangle, String>(chesmamcount);
private static Hashtable<Rectangle, String> httwo=new Hashtable<Rectangle, String>(chesmamcount);
private static Rectangle rectangle;

public static void Chessmanload(int width,int height){
Chessman.width=(width-2*startx)/(cols-1);
Chessman.height=(height-2*starty)/(rows-1);

int startone=-1;
int starttwo=-1;
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
if(i==0||(i==2&&(j==1||j==7))||(i==3&&j%2==0)){
startone++;
rectangle=new Rectangle();
rectangle.setRect(startx+width*j, starty+height*i, width, height);
htone.put(rectangle, strchesmanone[startone]);
System.out.print(htone.size());
}else if(i==9||(i==7&&(j==1||j==7))||(i==6&&j%2==0)){
starttwo++;
rectangle=new Rectangle();
rectangle.setRect(startx+width*j, starty+height*i, width, height);
httwo.put(rectangle, strchesmantwo[starttwo]);
}
}
}
startone=-1;
starttwo=-1;
}
为什么htone,httwo中只能加入最后一个元素,先加入的元素的都会被覆盖?
我想把16个元素都加入htone或httwo应该怎样写啊?
请各位高手指点,先谢谢了。