我正在尝试完成一个项目,虽然我已经尝试过,但我似乎无法做到这一点.这是枚举:
public enum Symbols {
/**
* The Seven
*/
SEVEN(12,"images/seven.jpg"),
/**
* The Watermelon
*/
WATERMELON(10,"images/watermelon.jpg"),
/**
* The Orange
*/
ORANGE(8,"images/orange.jpg"),
/**
* The Plum
*/
PLUM(6,"images/plum.jpg"),
/**
* The Lemon
*/
LEMON(4,"images/lemon.jpg"),
/**
* The Cherry
*/
CHERRY(2,"images/cherry.jpg");
private int payout; // Symbol payout value
private BufferedImage image; // Symbol image
private String icon; // Symbol file name
/** Constructor - Payout must be positive and even, file name must not be null
* @param payout - Symbol payout amount
* @param icon - Symbol image file name
*/
Symbols(int payout, String icon){
this.payout = payout;
this.icon = icon;
loadImage(icon);
}
/** Copy Constructor - Symbol must not be null
* @param s - A single symbol
*/
Symbols(Symbols s){
payout = s.payout;
icon = s.icon;
loadImage(icon);
}
现在我可以进入main并创建一个名为“s”的符号,如下所示:
Symbols s = Symbols.CHERRY;
但是我无法使用给定的复制构造函数制作“s”的副本:
Symbols t = Symbols(s);
如果我尝试这样做,我会收到错误:“Symbols类型的方法符号(符号)未定义.”
谢谢