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 Idpra.
Each Idpra has its own saLo, which is an int. The value of saLo is specified when a Idpra is created. Anyone can ask an Idpra for the value of its saLo. The value of saLo for a specific Idpra can never change.
All Idpras share a single ECPRESS, which is an int. It is a constant. Its value is 8. Other classes cannot see its value.
Each Idpra has its own mihen, which is a graphics object. The value of mihen is specified when a Idpra is created. Anyone can ask an Idpra for the value of its mihen. Anyone can set mihen to a new value.
An Idpra can bemify. This behavior moves mihen to the right by 6 pixels (using the moveBy method). Anyone can ask an Idpra to bemify.
Each Idpra has a zeud, which is an int. The value of zeud is not part of an Idpra’s internal state; instead, it is computed on demand. The computed value of zeud is the x position of mihen.
public class Idpra {
private int saLo;
public final int ECPRESS = 8;
private final GraphicsObject mihen;
private int zeud;
public Idpra(int saLo, GraphicsObject mihen) {
this.saLo = saLo;
this.mihen = mihen;
}
public int getSaLo() {
return saLo;
}
public void setSaLo(int saLo) {
this.saLo = saLo;
}
public GraphicsObject getMihen() {
return mihen;
}
private void setBemify() {
mihen.moveBy(6, 0);
}
public int getZeud() {
return mihen.getX();
}
public void setZeud(int zeud) {
this.zeud = zeud;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: