今、私はBrick.javaを持っています。これは、同じパッケージ(デフォルトパッケージ)に含まれているBreakoutCourt.javaで使用するレベル列挙を含んでいます。インポートを解決できませんか?
インポート時にBrick.level; BreakoutCourtで、「インポートブリックを解決できません」というメッセージが表示されます。私は静的なBrick.Levelをインポートしてもそのメッセージを受け取る! Brick.javaに含まれる
レベルがENUMは次のようになります。
public class Brick {
public static final int BWIDTH = 60;
public static final int BHEIGHT = 20;
private int xPos, yPos;
private Level brickLevel;
//This sets up the different levels of bricks.
enum Level{
LUNATIC (4, 40, Color.MAGENTA),
HARD (3, 30, Color.PINK),
MEDIUM (2, 20, Color.BLUE),
EASY (1, 10, Color.CYAN),
DEAD (0, 0, Color.WHITE);
private int hitpoints;
private int points;
private Color color;
Level(int hitpoints, int points, Color color){
this.hitpoints = hitpoints;
this.points = points;
this.color=color;
}
public int getPoints(){
return points;
}
public Color getColor(){
return color;
}
}
//rest of brick class goes under the enum
そして、私はこのようBreakoutCourtでそれを使用します。
//Generates the bricks.
for(int i = 0; i < 8; ++i){
ArrayList<Brick> temp = new ArrayList<Brick>();
Level rowColor = null;
switch(i){
//There are two rows per type of brick.
case 0:
case 1:
rowColor = Level.EASY;
break;
case 2:
case 3:
rowColor = Level.HARD;
break;
case 4:
case 5:
rowColor = Level.LUNATIC;
break;
case 6:
case 7:
default:
rowColor = Level.MEDIUM;
break;
}
for(int j = 0; j < numBrick; j++){
Brick tempBrick = new Brick((j * Brick.BWIDTH), ((i+2) * Brick.BHEIGHT), rowColor);
temp.add(tempBrick);
}
は私が間違って何をしているのですか?お手伝いありがとう!
フムを持っている必要があり
、私はまだインポートが解決できないそうです。列挙型はパブリッククラスにあるはずですか? – flymonkey
Brick.javaの上部にpackageステートメントがありますか? – ricochet1k