开发者

Java cannot find symbol enum

开发者 https://www.devze.com 2023-01-03 09:54 出处:网络
I\'m modeling a chess game on Java, and I\'m having some problem.Here\'s what the code looks like (the relevant parts):

I'm modeling a chess game on Java, and I'm having some problem. Here's what the code looks like (the relevant parts):

Enum class Couleur.java:

开发者_StackOverflow社区
public enum Couleur {BLANC, NOIR}

Piece.java:

public abstract class Piece {
(...)
  public Piece(Couleur couleurParam){
    this.couleurPiece = couleurParam;
  }
(...)
}

And finally Tour.java:

public class Tour extends Piece {
(...)
  public Tour(Couleur couleurParam){
    super(couleurParam);
  }
(...)
}

All the .java files are in the same folder. Yet at compile I get a "cannot find symbol symbol : variable NOIR location: class Plateau"

(Plateau is the class that instantiates Tour.)

Can anyone help me figure out what's wrong here?

Many thanks,

JDelage


It doesn't help that you've not shown the line in Plateau that fails to compile. If you're getting compilation errors, please post the bit of code which doesn't compile. My guess is you're doing this:

new Tour(NOIR)

instead of

new Tour(Couleur.NOIR)

The only times you can refer to enum values without qualifying them like this are:

  • Within the enum itself
  • Using a static import
  • In a switch statement
0

精彩评论

暂无评论...
验证码 换一张
取 消