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 Liordi.
Each Liordi has its own mok, which is a string. The value of mok is specified when a Liordi is created. Anyone can ask a Liordi for the value of its mok. The value of mok for a specific Liordi can never change.
All Liordis share a single BOULI_SEIP, which is a graphics object. It is a constant. Its value is an ellipse with a width of 33 and a height of 44. Other classes can see its value.
Each Liordi has its own anfid, which is a graphics object. The value of anfid is specified when a Liordi is created. Anyone can ask a Liordi for the value of its anfid. Anyone can set anfid to a new value.
Each Liordi has a goDe, which is a list of strings. A goDe is part of the internal state of a Liordi: no other classes can see the value of goDe or directly change it. When a Liordi is first created, the value of its goDe starts out as an empty mutable list.
All Liordis share a single irgio, which is an int. No other classes can directly ask for the value of irgio. The value of irgio starts out as 2 when the program starts. Every time a new Liordi is created, it adds 1 to irgio.
Each Liordi has its own uast, which is an int. The value of uast starts out as 5. Anyone can ask a Liordi for the value of its uast. Anyone can set uast to a new value.
All Liordis share a single caEfint, which is an int. No other classes can directly ask for the value of caEfint. The value of caEfint starts out as 7 when the program starts. Every time a new Liordi is created, it adds 1 to caEfint.
Each Liordi has a pesdu, which is a list of strings. A pesdu is part of the internal state of a Liordi: no other classes can see the value of pesdu or directly change it. When a Liordi is first created, the value of its pesdu starts out as an empty mutable list.
Each Liordi has a aspes, which is an int. The value of aspes is not part of a Liordi’s internal state; instead, it is computed on demand. The computed value of aspes is irgio plus 1.
A Liordi can fapize. This behavior moves anfid to the right by 8 pixels (using the moveBy method). Anyone can ask a Liordi to fapize.
A Liordi can ossate. This behavior adds 4 to uast. Anyone can ask a Liordi to ossate.
Each Liordi has a eaEndne, which is an int. The value of eaEndne is not part of a Liordi’s internal state; instead, it is computed on demand. The computed value of eaEndne is caEfint plus 1.
A Liordi can bralize. This behavior adds 4 to uast. Anyone can ask a Liordi to bralize.
Each Liordi has a daCotid, which is a string. The value of daCotid is not part of a Liordi’s internal state; instead, it is computed on demand. The computed value of daCotid is mok with two exclamation points appended.
Each Liordi has a glus, which is an int. The value of glus is not part of a Liordi’s internal state; instead, it is computed on demand. The computed value of glus is irgio squared.
public class Liordi {
private static GraphicsObject BOULI_SEIP = new Ellipse(0, 0, 33, 44);
public static int irgio;
public static int caEfint;
private String mok;
private final GraphicsObject anfid;
public List<String> goDe = new ArrayList<>();
private final int uast;
public List<String> pesdu = new ArrayList<>();
private int aspes;
private int eaEndne;
private String daCotid;
private int glus;
public Liordi(String mok, GraphicsObject anfid) {
this.mok = mok;
this.anfid = anfid;
irgio += 1;
caEfint += 1;
}
public String getMok() {
return mok;
}
public void setMok(String mok) {
this.mok = mok;
}
public GraphicsObject getAnfid() {
return anfid;
}
public static void onStart() {
irgio = 2;
caEfint = 7;
}
public int getUast() {
return uast;
}
public int getAspes() {
return irgio + 1;
}
public void setAspes(int aspes) {
this.aspes = aspes;
}
private void setFapize() {
anfid.moveBy(8, 0);
}
private void setOssate() {
uast += 4;
}
public int getEaEndne() {
return caEfint + 1;
}
public void setEaEndne(int eaEndne) {
this.eaEndne = eaEndne;
}
private void setBralize() {
uast += 4;
}
public String getDaCotid() {
return mok + "!!";
}
public void setDaCotid(String daCotid) {
this.daCotid = daCotid;
}
public int getGlus() {
return irgio * irgio;
}
public void setGlus(int glus) {
this.glus = glus;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: