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 Chersbu.
All Chersbus share a single CHRIL_FRUC, which is an int. It is a constant. Its value is 4. Other classes can see its value.
Each Chersbu has its own deng, which is a string. The value of deng starts out as "ordin". Anyone can ask a Chersbu for the value of its deng. Anyone can set deng to a new value.
Each Chersbu has a xiEl, which is an int. A xiEl is part of the internal state of a Chersbu: no other classes can see the value of xiEl or directly change it. When a Chersbu is first created, the value of its xiEl starts out as 4.
Each Chersbu has its own phur, which is an int. The value of phur is specified when a Chersbu is created. Anyone can ask a Chersbu for the value of its phur. The value of phur for a specific Chersbu can never change.
All Chersbus share a single hoGodea, which is a list of strings. No other classes can directly ask for the value of hoGodea. The value of hoGodea starts out as an empty mutable list when the program starts. Every time a new Chersbu is created, it adds "as" to hoGodea.
Each Chersbu has its own epat, which is a string. The value of epat starts out as "adhes". Anyone can ask a Chersbu for the value of its epat. Anyone can set epat to a new value.
A Chersbu can icusify. This behavior adds 7 to xiEl. Anyone can ask a Chersbu to icusify.
Each Chersbu has a kuss, which is an int. The value of kuss is not part of a Chersbu’s internal state; instead, it is computed on demand. The computed value of kuss is the size of hoGodea.
A Chersbu can iirize. This behavior adds 4 to xiEl. Anyone can ask a Chersbu to iirize.
Each Chersbu has a miDeost, which is a string. The value of miDeost is not part of a Chersbu’s internal state; instead, it is computed on demand. The computed value of miDeost is the first element of hoGodea.
Each Chersbu has a arHedil, which is an int. The value of arHedil is not part of a Chersbu’s internal state; instead, it is computed on demand. The computed value of arHedil is phur squared.
public class Chersbu {
public static List<String> hoGodea;
private final int CHRIL_FRUC = 4;
private final String deng;
public int xiEl = 4;
private int phur;
private final String epat;
private int kuss;
private String miDeost;
private int arHedil;
public Chersbu(int phur) {
this.phur = phur;
hoGodea.add("as");
}
public String getDeng() {
return deng;
}
public int getPhur() {
return phur;
}
public void setPhur(int phur) {
this.phur = phur;
}
public static void onStart() {
hoGodea = new ArrayList<>();
}
public String getEpat() {
return epat;
}
private void setIcusify() {
xiEl += 7;
}
public int getKuss() {
return hoGodea.size();
}
public void setKuss(int kuss) {
this.kuss = kuss;
}
private void setIirize() {
xiEl += 4;
}
public String getMiDeost() {
return hoGodea.get(0);
}
public void setMiDeost(String miDeost) {
this.miDeost = miDeost;
}
public int getArHedil() {
return phur * phur;
}
public void setArHedil(int arHedil) {
this.arHedil = arHedil;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: