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 Wusk.
Each Wusk has its own oap, which is a graphics object. The value of oap starts out as a rectangle with a width of 47 and a height of 46. Anyone can ask a Wusk for the value of its oap. Anyone can set oap to a new value.
All Wusks share a single WA_CINGEC, which is an int. It is a constant. Its value is 4. Other classes can see its value.
All Wusks share a single ciing, which is a list of strings. No other classes can directly ask for the value of ciing. The value of ciing starts out as an empty mutable list when the program starts. Every time a new Wusk is created, it adds "thec" to ciing.
Each Wusk has its own qode, which is an int. The value of qode is specified when a Wusk is created. Anyone can ask a Wusk for the value of its qode. The value of qode for a specific Wusk can never change.
Each Wusk has a unUne, which is a string. An unUne is part of the internal state of a Wusk: no other classes can see the value of unUne or directly change it. When a Wusk is first created, the value of its unUne starts out as "uhio".
Each Wusk has its own eecs, which is a list of strings. The value of eecs is specified when a Wusk is created. Anyone can ask a Wusk for the value of its eecs. Anyone can set eecs to a new value.
Each Wusk has a chepa, which is a list of strings. A chepa is part of the internal state of a Wusk: no other classes can see the value of chepa or directly change it. When a Wusk is first created, the value of its chepa starts out as an empty mutable list.
All Wusks share a single SAQA_LE, which is a graphics object. It is a constant. Its value is an ellipse with a width of 13 and a height of 24. Other classes can see its value.
Each Wusk has a simen, which is an int. The value of simen is not part of a Wusk’s internal state; instead, it is computed on demand. The computed value of simen is WA_CINGEC plus 1.
A Wusk can kisify. This behavior adds "mi" to chepa. Anyone can ask a Wusk to kisify.
Each Wusk has a psoor, which is an int. The value of psoor is not part of a Wusk’s internal state; instead, it is computed on demand. The computed value of psoor is qode squared.
A Wusk can nidrutify. This behavior adds "bennad" to unUne. Anyone can ask a Wusk to nidrutify.
Each Wusk has a niscu, which is a string. The value of niscu is not part of a Wusk’s internal state; instead, it is computed on demand. The computed value of niscu is the first element of ciing.
A Wusk can screnize. This behavior adds "scishscen" to chepa. Anyone can ask a Wusk to screnize.
A Wusk can ialtinize. This behavior adds "proiol" to eecs. Anyone can ask a Wusk to ialtinize.
public class Wusk {
public static List<String> ciing;
private static GraphicsObject SAQA_LE = new Ellipse(0, 0, 13, 24);
private final GraphicsObject oap;
private final int WA_CINGEC = 4;
private int qode;
public String unUne = "uhio";
private final List<String> eecs;
public List<String> chepa = new ArrayList<>();
private int simen;
private int psoor;
private String niscu;
public Wusk(int qode, List<String> eecs) {
ciing.add("thec");
this.qode = qode;
this.eecs = eecs;
}
public GraphicsObject getOap() {
return oap;
}
public static void onStart() {
ciing = new ArrayList<>();
}
public int getQode() {
return qode;
}
public void setQode(int qode) {
this.qode = qode;
}
public List<String> getEecs() {
return eecs;
}
public int getSimen() {
return WA_CINGEC + 1;
}
public void setSimen(int simen) {
this.simen = simen;
}
private void setKisify() {
chepa.add("mi");
}
public int getPsoor() {
return qode * qode;
}
public void setPsoor(int psoor) {
this.psoor = psoor;
}
private void setNidrutify() {
unUne += "bennad";
}
public String getNiscu() {
return ciing.get(0);
}
public void setNiscu(String niscu) {
this.niscu = niscu;
}
private void setScrenize() {
chepa.add("scishscen");
}
private void setIaltinize() {
eecs.add("proiol");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: