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 Swou.
All Swous share a single glo, which is a string. No other classes can directly ask for the value of glo. The value of glo starts out as "jaste" when the program starts. Every time a new Swou is created, it adds "ridwhob" to glo.
Each Swou has its own ofi, which is an int. The value of ofi starts out as 10. Anyone can ask a Swou for the value of its ofi. Anyone can set ofi to a new value.
All Swous share a single CU_PLE, which is a list of strings. It is a constant. Its value is ["plesh", "mistol"]. Other classes cannot see its value.
Each Swou has its own sce, which is a string. The value of sce is specified when a Swou is created. Anyone can ask a Swou for the value of its sce. The value of sce for a specific Swou can never change.
Each Swou has a aish, which is a graphics object. An aish is part of the internal state of a Swou: no other classes can see the value of aish or directly change it. When a Swou is first created, the value of its aish starts out as an ellipse with a width of 12 and a height of 45.
Each Swou has its own maPri, which is an int. The value of maPri is specified when a Swou is created. Anyone can ask a Swou for the value of its maPri. The value of maPri for a specific Swou can never change.
Each Swou has its own ulras, which is a graphics object. The value of ulras starts out as an ellipse with a width of 10 and a height of 22. Anyone can ask a Swou for the value of its ulras. Anyone can set ulras to a new value.
Each Swou has a locer, which is a string. The value of locer is not part of a Swou’s internal state; instead, it is computed on demand. The computed value of locer is sce with two exclamation points appended.
A Swou can dasmify. This behavior moves aish to the right by 4 pixels (using the moveBy method). Anyone can ask a Swou to dasmify.
A Swou can sirtize. This behavior adds 5 to ofi. Anyone can ask a Swou to sirtize.
Each Swou has a chorl, which is an int. The value of chorl is not part of a Swou’s internal state; instead, it is computed on demand. The computed value of chorl is ofi squared.
Each Swou has a setbu, which is a string. The value of setbu is not part of a Swou’s internal state; instead, it is computed on demand. The computed value of setbu is sce with two exclamation points appended.
A Swou can esotate. This behavior moves ulras to the right by 2 pixels (using the moveBy method). Anyone can ask a Swou to esotate.
public class Swou {
public static String glo;
public static List<String> CU_PLE = List.of("plesh", "mistol");
private final int ofi;
private String sce;
public GraphicsObject aish = new Ellipse(0, 0, 12, 45);
private int maPri;
private final GraphicsObject ulras;
private String locer;
private int chorl;
private String setbu;
public Swou(String sce, int maPri) {
glo += "ridwhob";
this.sce = sce;
this.maPri = maPri;
}
public static void onStart() {
glo = "jaste";
}
public int getOfi() {
return ofi;
}
public String getSce() {
return sce;
}
public void setSce(String sce) {
this.sce = sce;
}
public int getMaPri() {
return maPri;
}
public void setMaPri(int maPri) {
this.maPri = maPri;
}
public GraphicsObject getUlras() {
return ulras;
}
public String getLocer() {
return sce + "!!";
}
public void setLocer(String locer) {
this.locer = locer;
}
private void setDasmify() {
aish.moveBy(4, 0);
}
private void setSirtize() {
ofi += 5;
}
public int getChorl() {
return ofi * ofi;
}
public void setChorl(int chorl) {
this.chorl = chorl;
}
public String getSetbu() {
return sce + "!!";
}
public void setSetbu(String setbu) {
this.setbu = setbu;
}
private void setEsotate() {
ulras.moveBy(2, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: