Translate the specification below into an idiomatic Java class definition.
(In this context, "idiomatic" means following the common style and conventions of the language.)
One kind of thing that exists in our model is an Amwo.
Each Amwo has its own ces, which is an int. The value of ces starts out as 5. Anyone can ask an Amwo for the value of its ces. Anyone can set ces to a new value.
All Amwos share a single VIRPHRENT, which is a list of strings. It is a constant. Its value is ["troli", "er"]. Other classes can see its value.
Each Amwo has a oedan, which is an int. The value of oedan is not part of an Amwo’s internal state; instead, it is computed on demand. The computed value of oedan is ces plus 4.
public class Amwo {
private static List<String> VIRPHRENT = List.of("troli", "er");
private final int ces;
private int oedan;
public Amwo() {
}
public int getCes() {
return ces;
}
public int getOedan() {
return ces + 4;
}
public void setOedan(int oedan) {
this.oedan = oedan;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: