Возможно ли, чтобы enum изменил свое значение (изнутри себя)? Может быть, легче понять, что я имею в виду с кодом:
enum Rate {
VeryBad(1),
Bad(2),
Average(3),
Good(4),
Excellent(5);
private int rate;
private Rate(int rate) {
this.rate = rate;
}
public void increateRating() {
//is it possible to make the enum variable increase?
//this is, if right now this enum has as value Average, after calling this
//method to have it change to Good?
}
}
Это то, чего я хочу достичь:
Rate rate = Rate.Average;
System.out.println(rate); //prints Average;
rate.increaseRating();
System.out.println(rate); //prints Good
Спасибо