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 Dorir.
All Dorirs share a single MOIOEDCED, which is an int. It is a constant. Its value is 18. Other classes can see its value.
All Dorirs share a single ent, which is a string. No other classes can directly ask for the value of ent. The value of ent starts out as "niwn" when the program starts. Every time a new Dorir is created, it adds "me" to ent.
Each Dorir has a hou, which is a list of strings. A hou is part of the internal state of a Dorir: no other classes can see the value of hou or directly change it. When a Dorir is first created, the value of its hou starts out as an empty mutable list.
Each Dorir has its own osLipro, which is an int. The value of osLipro starts out as 13. Anyone can ask a Dorir for the value of its osLipro. Anyone can set osLipro to a new value.
Each Dorir has its own ubes, which is an int. The value of ubes is specified when a Dorir is created. Anyone can ask a Dorir for the value of its ubes. The value of ubes for a specific Dorir can never change.
Each Dorir has its own siIc, which is a list of strings. The value of siIc is specified when a Dorir is created. Anyone can ask a Dorir for the value of its siIc. The value of siIc for a specific Dorir can never change.
All Dorirs share a single ES_WHAI, which is a string. It is a constant. Its value is "spedba". Other classes can see its value.
All Dorirs share a single naThien, which is a list of strings. No other classes can directly ask for the value of naThien. The value of naThien starts out as an empty mutable list when the program starts. Every time a new Dorir is created, it adds "snahe" to naThien.
A Dorir can etonsate. This behavior adds "bipt" to ent. Anyone can ask a Dorir to etonsate.
Each Dorir has a ceIcec, which is an int. The value of ceIcec is not part of a Dorir’s internal state; instead, it is computed on demand. The computed value of ceIcec is the length of ES_WHAI.
Each Dorir has a anTo, which is a string. The value of anTo is not part of a Dorir’s internal state; instead, it is computed on demand. The computed value of anTo is the first element of naThien.
A Dorir can ubrohify. This behavior adds "dosust" to hou. Anyone can ask a Dorir to ubrohify.
Each Dorir has a nurd, which is an int. The value of nurd is not part of a Dorir’s internal state; instead, it is computed on demand. The computed value of nurd is MOIOEDCED squared.
A Dorir can prisify. This behavior adds 5 to osLipro. Anyone can ask a Dorir to prisify.
Each Dorir has a loLos, which is an int. The value of loLos is not part of a Dorir’s internal state; instead, it is computed on demand. The computed value of loLos is the size of siIc.
public class Dorir {
public static String ent;
private static String ES_WHAI = "spedba";
public static List<String> naThien;
private final int MO_IO_EDCED = 18;
public List<String> hou = new ArrayList<>();
private final int osLipro;
private int ubes;
private List<String> siIc;
private int ceIcec;
private String anTo;
private int nurd;
private int loLos;
public Dorir(int ubes, List<String> siIc) {
ent += "me";
this.ubes = ubes;
this.siIc = siIc;
naThien.add("snahe");
}
public static void onStart() {
ent = "niwn";
naThien = new ArrayList<>();
}
public int getOsLipro() {
return osLipro;
}
public int getUbes() {
return ubes;
}
public void setUbes(int ubes) {
this.ubes = ubes;
}
public List<String> getSiIc() {
return siIc;
}
public void setSiIc(List<String> siIc) {
this.siIc = siIc;
}
private void setEtonsate() {
ent += "bipt";
}
public int getCeIcec() {
return ES_WHAI.length();
}
public void setCeIcec(int ceIcec) {
this.ceIcec = ceIcec;
}
public String getAnTo() {
return naThien.get(0);
}
public void setAnTo(String anTo) {
this.anTo = anTo;
}
private void setUbrohify() {
hou.add("dosust");
}
public int getNurd() {
return MO_IO_EDCED * MO_IO_EDCED;
}
public void setNurd(int nurd) {
this.nurd = nurd;
}
private void setPrisify() {
osLipro += 5;
}
public int getLoLos() {
return siIc.size();
}
public void setLoLos(int loLos) {
this.loLos = loLos;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: