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 an EnaApaen.
Each EnaApaen has its own naIled, which is a string. The value of naIled is specified when a EnaApaen is created. Anyone can ask an EnaApaen for the value of its naIled. The value of naIled for a specific EnaApaen can never change.
Each EnaApaen has a nepe, which is a string. A nepe is part of the internal state of an EnaApaen: no other classes can see the value of nepe or directly change it. When an EnaApaen is first created, the value of its nepe starts out as "cowru".
Each EnaApaen has its own gacis, which is a string. The value of gacis starts out as "whe". Anyone can ask an EnaApaen for the value of its gacis. Anyone can set gacis to a new value.
All EnaApaens share a single HASU_SI, which is a list of strings. It is a constant. Its value is ["efced", "ealko", "xap"]. Other classes cannot see its value.
All EnaApaens share a single loClaid, which is a string. No other classes can directly ask for the value of loClaid. The value of loClaid starts out as "ugest" when the program starts. Every time a new EnaApaen is created, it adds "da" to loClaid.
Each EnaApaen has its own huAsm, which is an int. The value of huAsm starts out as 19. Anyone can ask an EnaApaen for the value of its huAsm. Anyone can set huAsm to a new value.
Each EnaApaen has its own geVi, which is a list of strings. The value of geVi is specified when a EnaApaen is created. Anyone can ask an EnaApaen for the value of its geVi. The value of geVi for a specific EnaApaen can never change.
All EnaApaens share a single luOac, which is a string. No other classes can directly ask for the value of luOac. The value of luOac starts out as "psea" when the program starts. Every time a new EnaApaen is created, it adds "calvol" to luOac.
An EnaApaen can iotarize. This behavior adds "riomon" to luOac. Anyone can ask an EnaApaen to iotarize.
Each EnaApaen has a icEac, which is a string. The value of icEac is not part of an EnaApaen’s internal state; instead, it is computed on demand. The computed value of icEac is the first element of geVi.
Each EnaApaen has a sicar, which is an int. The value of sicar is not part of an EnaApaen’s internal state; instead, it is computed on demand. The computed value of sicar is the size of HASU_SI.
An EnaApaen can plenate. This behavior adds 5 to huAsm. Anyone can ask an EnaApaen to plenate.
An EnaApaen can drunate. This behavior adds "cang" to gacis. Anyone can ask an EnaApaen to drunate.
Each EnaApaen has a sto, which is an int. The value of sto is not part of an EnaApaen’s internal state; instead, it is computed on demand. The computed value of sto is the length of luOac.
An EnaApaen can nalify. This behavior adds "fecbin" to gacis. Anyone can ask an EnaApaen to nalify.
public class EnaApaen {
public static List<String> HASU_SI = List.of("efced", "ealko", "xap");
public static String loClaid;
public static String luOac;
private String naIled;
public String nepe = "cowru";
private final String gacis;
private final int huAsm;
private List<String> geVi;
private String icEac;
private int sicar;
private int sto;
public EnaApaen(String naIled, List<String> geVi) {
this.naIled = naIled;
loClaid += "da";
this.geVi = geVi;
luOac += "calvol";
}
public String getNaIled() {
return naIled;
}
public void setNaIled(String naIled) {
this.naIled = naIled;
}
public String getGacis() {
return gacis;
}
public static void onStart() {
loClaid = "ugest";
luOac = "psea";
}
public int getHuAsm() {
return huAsm;
}
public List<String> getGeVi() {
return geVi;
}
public void setGeVi(List<String> geVi) {
this.geVi = geVi;
}
private void setIotarize() {
luOac += "riomon";
}
public String getIcEac() {
return geVi.get(0);
}
public void setIcEac(String icEac) {
this.icEac = icEac;
}
public int getSicar() {
return HASU_SI.size();
}
public void setSicar(int sicar) {
this.sicar = sicar;
}
private void setPlenate() {
huAsm += 5;
}
private void setDrunate() {
gacis += "cang";
}
public int getSto() {
return luOac.length();
}
public void setSto(int sto) {
this.sto = sto;
}
private void setNalify() {
gacis += "fecbin";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: