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 KniPradprant.
Each KniPradprant has its own ilSilmi, which is a graphics object. The value of ilSilmi is specified when a KniPradprant is created. Anyone can ask a KniPradprant for the value of its ilSilmi. Anyone can set ilSilmi to a new value.
All KniPradprants share a single shenu, which is an int. No other classes can directly ask for the value of shenu. The value of shenu starts out as 13 when the program starts. Every time a new KniPradprant is created, it adds 4 to shenu.
All KniPradprants share a single BRI_SLIR, which is a string. It is a constant. Its value is "nescuad". Other classes cannot see its value.
Each KniPradprant has a ooAclac, which is a graphics object. An ooAclac is part of the internal state of a KniPradprant: no other classes can see the value of ooAclac or directly change it. When a KniPradprant is first created, the value of its ooAclac starts out as a rectangle with a width of 26 and a height of 32.
Each KniPradprant has a rost, which is an int. The value of rost is not part of a KniPradprant’s internal state; instead, it is computed on demand. The computed value of rost is the x position of ilSilmi.
A KniPradprant can usonate. This behavior moves ooAclac to the right by 8 pixels (using the moveBy method). Anyone can ask a KniPradprant to usonate.
Each KniPradprant has a mez, which is an int. The value of mez is not part of a KniPradprant’s internal state; instead, it is computed on demand. The computed value of mez is the x position of ilSilmi.
public class KniPradprant {
public static int shenu;
public static String BRI_SLIR = "nescuad";
private final GraphicsObject ilSilmi;
public GraphicsObject ooAclac = new Rectangle(0, 0, 26, 32);
private int rost;
private int mez;
public KniPradprant(GraphicsObject ilSilmi) {
this.ilSilmi = ilSilmi;
shenu += 4;
}
public GraphicsObject getIlSilmi() {
return ilSilmi;
}
public static void onStart() {
shenu = 13;
}
public int getRost() {
return ilSilmi.getX();
}
public void setRost(int rost) {
this.rost = rost;
}
private void setUsonate() {
ooAclac.moveBy(8, 0);
}
public int getMez() {
return ilSilmi.getX();
}
public void setMez(int mez) {
this.mez = mez;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: