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 Rackac.
All Rackacs share a single reEtour, which is a graphics object. No other classes can directly ask for the value of reEtour. The value of reEtour starts out as an ellipse with a width of 48 and a height of 31 when the program starts. Every time a new Rackac is created, it moves reEtour to the right by 5 pixels (using the moveBy method).
All Rackacs share a single OI_GROCENG, which is a list of strings. It is a constant. Its value is ["scupio", "ednel", "fis"]. Other classes can see its value.
Each Rackac has a uan, which is a graphics object. An uan is part of the internal state of a Rackac: no other classes can see the value of uan or directly change it. When a Rackac is first created, the value of its uan starts out as an ellipse with a width of 35 and a height of 20.
Each Rackac has its own enel, which is an int. The value of enel is specified when a Rackac is created. Anyone can ask a Rackac for the value of its enel. The value of enel for a specific Rackac can never change.
Each Rackac has its own gaiss, which is an int. The value of gaiss starts out as 3. Anyone can ask a Rackac for the value of its gaiss. Anyone can set gaiss to a new value.
All Rackacs share a single KEOUSU, which is a list of strings. It is a constant. Its value is ["si", "neis", "shellass"]. Other classes can see its value.
Each Rackac has its own apra, which is a string. The value of apra is specified when a Rackac is created. Anyone can ask a Rackac for the value of its apra. The value of apra for a specific Rackac can never change.
All Rackacs share a single saDac, which is an int. No other classes can directly ask for the value of saDac. The value of saDac starts out as 18 when the program starts. Every time a new Rackac is created, it adds 2 to saDac.
Each Rackac has a hePio, which is a string. The value of hePio is not part of a Rackac’s internal state; instead, it is computed on demand. The computed value of hePio is the first element of KEOUSU.
A Rackac can reswilify. This behavior moves uan to the right by 3 pixels (using the moveBy method). Anyone can ask a Rackac to reswilify.
Each Rackac has a clul, which is a string. The value of clul is not part of a Rackac’s internal state; instead, it is computed on demand. The computed value of clul is the first element of KEOUSU.
A Rackac can lipenize. This behavior adds 8 to saDac. Anyone can ask a Rackac to lipenize.
Each Rackac has a seng, which is an int. The value of seng is not part of a Rackac’s internal state; instead, it is computed on demand. The computed value of seng is enel squared.
A Rackac can citicify. This behavior adds 9 to gaiss. Anyone can ask a Rackac to citicify.
A Rackac can omlanify. This behavior adds 2 to gaiss. Anyone can ask a Rackac to omlanify.
public class Rackac {
public static GraphicsObject reEtour;
private static List<String> OI_GROCENG = List.of("scupio", "ednel", "fis");
private static List<String> KEOUSU = List.of("si", "neis", "shellass");
public static int saDac;
public GraphicsObject uan = new Ellipse(0, 0, 35, 20);
private int enel;
private final int gaiss;
private String apra;
private String hePio;
private String clul;
private int seng;
public Rackac(int enel, String apra) {
reEtour.moveBy(5, 0);
this.enel = enel;
this.apra = apra;
saDac += 2;
}
public static void onStart() {
reEtour = new Ellipse(0, 0, 48, 31);
saDac = 18;
}
public int getEnel() {
return enel;
}
public void setEnel(int enel) {
this.enel = enel;
}
public int getGaiss() {
return gaiss;
}
public String getApra() {
return apra;
}
public void setApra(String apra) {
this.apra = apra;
}
public String getHePio() {
return KEOUSU.get(0);
}
public void setHePio(String hePio) {
this.hePio = hePio;
}
private void setReswilify() {
uan.moveBy(3, 0);
}
public String getClul() {
return KEOUSU.get(0);
}
public void setClul(String clul) {
this.clul = clul;
}
private void setLipenize() {
saDac += 8;
}
public int getSeng() {
return enel * enel;
}
public void setSeng(int seng) {
this.seng = seng;
}
private void setCiticify() {
gaiss += 9;
}
private void setOmlanify() {
gaiss += 2;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: