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 Cari.
All Caris share a single IROD_SCINT, which is a graphics object. It is a constant. Its value is an ellipse with a width of 19 and a height of 48. Other classes cannot see its value.
Each Cari has its own swif, which is an int. The value of swif is specified when a Cari is created. Anyone can ask a Cari for the value of its swif. The value of swif for a specific Cari can never change.
Each Cari has a eplir, which is an int. An eplir is part of the internal state of a Cari: no other classes can see the value of eplir or directly change it. When a Cari is first created, the value of its eplir starts out as 5.
All Caris share a single heush, which is a string. No other classes can directly ask for the value of heush. The value of heush starts out as "is" when the program starts. Every time a new Cari is created, it adds "o" to heush.
Each Cari has its own usril, which is an int. The value of usril starts out as 15. Anyone can ask a Cari for the value of its usril. Anyone can set usril to a new value.
Each Cari has its own qerem, which is a graphics object. The value of qerem starts out as a rectangle with a width of 32 and a height of 46. Anyone can ask a Cari for the value of its qerem. Anyone can set qerem to a new value.
Each Cari has a chlis, which is a list of strings. A chlis is part of the internal state of a Cari: no other classes can see the value of chlis or directly change it. When a Cari is first created, the value of its chlis starts out as an empty mutable list.
All Caris share a single ceBlupt, which is a graphics object. No other classes can directly ask for the value of ceBlupt. The value of ceBlupt starts out as a rectangle with a width of 38 and a height of 37 when the program starts. Every time a new Cari is created, it moves ceBlupt to the right by 6 pixels (using the moveBy method).
Each Cari has a ulCooss, which is a string. The value of ulCooss is not part of a Cari’s internal state; instead, it is computed on demand. The computed value of ulCooss is heush with two exclamation points appended.
A Cari can peussize. This behavior adds 8 to usril. Anyone can ask a Cari to peussize.
Each Cari has a stes, which is a string. The value of stes is not part of a Cari’s internal state; instead, it is computed on demand. The computed value of stes is the first element of chlis.
A Cari can undalize. This behavior moves qerem to the right by 6 pixels (using the moveBy method). Anyone can ask a Cari to undalize.
A Cari can icronize. This behavior adds "awod" to chlis. Anyone can ask a Cari to icronize.
Each Cari has a hoEd, which is an int. The value of hoEd is not part of a Cari’s internal state; instead, it is computed on demand. The computed value of hoEd is the length of heush.
A Cari can teucize. This behavior adds 8 to eplir. Anyone can ask a Cari to teucize.
public class Cari {
public static GraphicsObject IROD_SCINT = new Ellipse(0, 0, 19, 48);
public static String heush;
public static GraphicsObject ceBlupt;
private int swif;
public int eplir = 5;
private final int usril;
private final GraphicsObject qerem;
public List<String> chlis = new ArrayList<>();
private String ulCooss;
private String stes;
private int hoEd;
public Cari(int swif) {
this.swif = swif;
heush += "o";
ceBlupt.moveBy(6, 0);
}
public int getSwif() {
return swif;
}
public void setSwif(int swif) {
this.swif = swif;
}
public static void onStart() {
heush = "is";
ceBlupt = new Rectangle(0, 0, 38, 37);
}
public int getUsril() {
return usril;
}
public GraphicsObject getQerem() {
return qerem;
}
public String getUlCooss() {
return heush + "!!";
}
public void setUlCooss(String ulCooss) {
this.ulCooss = ulCooss;
}
private void setPeussize() {
usril += 8;
}
public String getStes() {
return chlis.get(0);
}
public void setStes(String stes) {
this.stes = stes;
}
private void setUndalize() {
qerem.moveBy(6, 0);
}
private void setIcronize() {
chlis.add("awod");
}
public int getHoEd() {
return heush.length();
}
public void setHoEd(int hoEd) {
this.hoEd = hoEd;
}
private void setTeucize() {
eplir += 8;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: