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 HarEem.
Each HarEem has its own hanon, which is a list of strings. The value of hanon is specified when a HarEem is created. Anyone can ask a HarEem for the value of its hanon. The value of hanon for a specific HarEem can never change.
Each HarEem has its own wePhess, which is a string. The value of wePhess starts out as "en". Anyone can ask a HarEem for the value of its wePhess. Anyone can set wePhess to a new value.
All HarEems share a single enir, which is a list of strings. No other classes can directly ask for the value of enir. The value of enir starts out as an empty mutable list when the program starts. Every time a new HarEem is created, it adds "eni" to enir.
Each HarEem has a deCe, which is a list of strings. A deCe is part of the internal state of a HarEem: no other classes can see the value of deCe or directly change it. When a HarEem is first created, the value of its deCe starts out as an empty mutable list.
All HarEems share a single TRIACMA, which is a string. It is a constant. Its value is "pa". Other classes can see its value.
All HarEems share a single schos, which is a string. No other classes can directly ask for the value of schos. The value of schos starts out as "tro" when the program starts. Every time a new HarEem is created, it adds "oweaess" to schos.
All HarEems share a single IL_FLE, which is an int. It is a constant. Its value is 6. Other classes can see its value.
Each HarEem has a icEc, which is an int. The value of icEc is not part of a HarEem’s internal state; instead, it is computed on demand. The computed value of icEc is the size of enir.
A HarEem can obialate. This behavior adds "fasesm" to deCe. Anyone can ask a HarEem to obialate.
Each HarEem has a gotme, which is a string. The value of gotme is not part of a HarEem’s internal state; instead, it is computed on demand. The computed value of gotme is TRIACMA with two exclamation points appended.
A HarEem can isoutify. This behavior adds "sqooncoh" to schos. Anyone can ask a HarEem to isoutify.
A HarEem can oddosize. This behavior adds "thess" to enir. Anyone can ask a HarEem to oddosize.
Each HarEem has a trere, which is a string. The value of trere is not part of a HarEem’s internal state; instead, it is computed on demand. The computed value of trere is the first element of hanon.
public class HarEem {
public static List<String> enir;
private static String TRIACMA = "pa";
public static String schos;
private List<String> hanon;
private final String wePhess;
public List<String> deCe = new ArrayList<>();
private final int IL_FLE = 6;
private int icEc;
private String gotme;
private String trere;
public HarEem(List<String> hanon) {
this.hanon = hanon;
enir.add("eni");
schos += "oweaess";
}
public List<String> getHanon() {
return hanon;
}
public void setHanon(List<String> hanon) {
this.hanon = hanon;
}
public String getWePhess() {
return wePhess;
}
public static void onStart() {
enir = new ArrayList<>();
schos = "tro";
}
public int getIcEc() {
return enir.size();
}
public void setIcEc(int icEc) {
this.icEc = icEc;
}
private void setObialate() {
deCe.add("fasesm");
}
public String getGotme() {
return TRIACMA + "!!";
}
public void setGotme(String gotme) {
this.gotme = gotme;
}
private void setIsoutify() {
schos += "sqooncoh";
}
private void setOddosize() {
enir.add("thess");
}
public String getTrere() {
return hanon.get(0);
}
public void setTrere(String trere) {
this.trere = trere;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: