假设我在一个类中有以下代码:
enum Currency
{
PENNY(1), NICKEL(5), DIME(10), QUARTER(25);
private int value;
private Bonus(int value)
{
this.value = value;
}
public int getValue()
{
return value;
}
};
public class Coin
{
Currency c;
public Coin(Currency c)
{
this.c = c;
}
public void setCurrency(Currency c)
{
this.c = c;
}
}
如果我有一个单独的类来创建具有某个 Currency 枚举的 Coin 对象,我怎么能在那个单独的类中编写一个方法来将枚举从 PENNY 设置为 DIME?