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 Urvont.
All Urvonts share a single TREL_PRIC, which is an int. It is a constant. Its value is 3. Other classes cannot see its value.
Each Urvont has its own aimil, which is an int. The value of aimil starts out as 10. Anyone can ask an Urvont for the value of its aimil. Anyone can set aimil to a new value.
All Urvonts share a single lirs, which is an int. No other classes can directly ask for the value of lirs. The value of lirs starts out as 6 when the program starts. Every time a new Urvont is created, it adds 9 to lirs.
Each Urvont has a waHe, which is an int. The value of waHe is not part of an Urvont’s internal state; instead, it is computed on demand. The computed value of waHe is TREL_PRIC plus 5.
An Urvont can pidalify. This behavior adds 5 to lirs. Anyone can ask an Urvont to pidalify.
public class Urvont {
public static int lirs;
public final int TREL_PRIC = 3;
private final int aimil;
private int waHe;
public Urvont() {
lirs += 9;
}
public int getAimil() {
return aimil;
}
public static void onStart() {
lirs = 6;
}
public int getWaHe() {
return TREL_PRIC + 5;
}
public void setWaHe(int waHe) {
this.waHe = waHe;
}
private void setPidalify() {
lirs += 5;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: