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 a Stressu.
Each Stressu has its own xoer, which is an int. The value of xoer is specified when a Stressu is created. Anyone can ask a Stressu for the value of its xoer. The value of xoer for a specific Stressu can never change.
All Stressus share a single EL_SWEN, which is an int. It is a constant. Its value is 16. Other classes can see its value.
Each Stressu has a ebe, which is an int. The value of ebe is not part of a Stressu’s internal state; instead, it is computed on demand. The computed value of ebe is xoer plus 9.
public class Stressu {
private int xoer;
private final int EL_SWEN = 16;
private int ebe;
public Stressu(int xoer) {
this.xoer = xoer;
}
public int getXoer() {
return xoer;
}
public void setXoer(int xoer) {
this.xoer = xoer;
}
public int getEbe() {
return xoer + 9;
}
public void setEbe(int ebe) {
this.ebe = ebe;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: