<强势 > 类块 强 >
public class block {
public enum size {SMALL,MEDIUM,LARGE,XLARGE}
public String color;public size sz;
public block(String color, size sz) {
super();
this.color = color;
this.sz = sz;
}
public block() {
this.color="White";
this.sz=sz.SMALL;
}
public String toString() {
String result="My color is " + color + " and size=" + sz;
return result;}
< 坚固 > 分类行ofblock 坚固>
public class rowofBlocks extends block{
private block[] blocks;
private int numofBlocks;
public rowofBlocks(int numofBlocks){
//super();
this.numofBlocks=numofBlocks;
generateBlocks() ;
}
private void generateBlocks() {
this.blocks=new block[numofBlocks];
}
public String toString() {
for(int a=0;a<blocks.length;a++)
{
System.out.print( blocks[a]);
}
String a="d";
return a;
}
}
< 强势 > 类游戏Main 强 >
public class gameMain {
public static void main(String[] args) {
block b=new block();
b.setSz(block.size.LARGE);
b.setColor("WHITE");
rowofBlocks myrows=new rowofBlocks(3);
System.out.println(b);
System.out.println(myrows);
}}
我的意思是,我只是看到无核核素 而不是我的颜色是白色 当我试图创建数组区块时。