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 Pealsa.
All Pealsas share a single ptic, which is a graphics object. No other classes can directly ask for the value of ptic. The value of ptic starts out as an ellipse with a width of 15 and a height of 43 when the program starts. Every time a new Pealsa is created, it moves ptic to the right by 8 pixels (using the moveBy method).
Each Pealsa has a qoc, which is a string. A qoc is part of the internal state of a Pealsa: no other classes can see the value of qoc or directly change it. When a Pealsa is first created, the value of its qoc starts out as "ad".
Each Pealsa has its own ceba, which is a graphics object. The value of ceba starts out as an ellipse with a width of 44 and a height of 47. Anyone can ask a Pealsa for the value of its ceba. Anyone can set ceba to a new value.
All Pealsas share a single JOC_HOURESS, which is an int. It is a constant. Its value is 2. Other classes can see its value.
Each Pealsa has its own siha, which is a string. The value of siha is specified when a Pealsa is created. Anyone can ask a Pealsa for the value of its siha. The value of siha for a specific Pealsa can never change.
Each Pealsa has a enpri, which is a string. The value of enpri is not part of a Pealsa’s internal state; instead, it is computed on demand. The computed value of enpri is qoc with two exclamation points appended.
A Pealsa can esmify. This behavior moves ptic to the right by 6 pixels (using the moveBy method). Anyone can ask a Pealsa to esmify.
Each Pealsa has a ciEsmse, which is an int. The value of ciEsmse is not part of a Pealsa’s internal state; instead, it is computed on demand. The computed value of ciEsmse is JOC_HOURESS plus 4.
A Pealsa can edspanify. This behavior adds "ect" to qoc. Anyone can ask a Pealsa to edspanify.
public class Pealsa {
public static GraphicsObject ptic;
public String qoc = "ad";
private final GraphicsObject ceba;
private final int JOC_HOURESS = 2;
private String siha;
private String enpri;
private int ciEsmse;
public Pealsa(String siha) {
ptic.moveBy(8, 0);
this.siha = siha;
}
public static void onStart() {
ptic = new Ellipse(0, 0, 15, 43);
}
public GraphicsObject getCeba() {
return ceba;
}
public String getSiha() {
return siha;
}
public void setSiha(String siha) {
this.siha = siha;
}
public String getEnpri() {
return qoc + "!!";
}
public void setEnpri(String enpri) {
this.enpri = enpri;
}
private void setEsmify() {
ptic.moveBy(6, 0);
}
public int getCiEsmse() {
return JOC_HOURESS + 4;
}
public void setCiEsmse(int ciEsmse) {
this.ciEsmse = ciEsmse;
}
private void setEdspanify() {
qoc += "ect";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: