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 Chos.
Each Chos has its own poad, which is an int. The value of poad is specified when a Chos is created. Anyone can ask a Chos for the value of its poad. The value of poad for a specific Chos can never change.
All Choss share a single enPhui, which is a string. No other classes can directly ask for the value of enPhui. The value of enPhui starts out as "smari" when the program starts. Every time a new Chos is created, it adds "sairfu" to enPhui.
Each Chos has a malan, which is a graphics object. A malan is part of the internal state of a Chos: no other classes can see the value of malan or directly change it. When a Chos is first created, the value of its malan starts out as a rectangle with a width of 48 and a height of 12.
Each Chos has its own mous, which is a list of strings. The value of mous starts out as an empty mutable list. Anyone can ask a Chos for the value of its mous. Anyone can set mous to a new value.
All Choss share a single ER_ILTI, which is an int. It is a constant. Its value is 10. Other classes can see its value.
Each Chos has a ial, which is an int. The value of ial is not part of a Chos’s internal state; instead, it is computed on demand. The computed value of ial is poad plus 8.
A Chos can qoedize. This behavior adds "pilac" to enPhui. Anyone can ask a Chos to qoedize.
A Chos can beperate. This behavior adds "ert" to mous. Anyone can ask a Chos to beperate.
Each Chos has a fedda, which is a string. The value of fedda is not part of a Chos’s internal state; instead, it is computed on demand. The computed value of fedda is enPhui with two exclamation points appended.
public class Chos {
public static String enPhui;
private int poad;
public GraphicsObject malan = new Rectangle(0, 0, 48, 12);
private final List<String> mous;
private final int ER_ILTI = 10;
private int ial;
private String fedda;
public Chos(int poad) {
this.poad = poad;
enPhui += "sairfu";
}
public int getPoad() {
return poad;
}
public void setPoad(int poad) {
this.poad = poad;
}
public static void onStart() {
enPhui = "smari";
}
public List<String> getMous() {
return mous;
}
public int getIal() {
return poad + 8;
}
public void setIal(int ial) {
this.ial = ial;
}
private void setQoedize() {
enPhui += "pilac";
}
private void setBeperate() {
mous.add("ert");
}
public String getFedda() {
return enPhui + "!!";
}
public void setFedda(String fedda) {
this.fedda = fedda;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: