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 Nicho.
All Nichos share a single PLEHED, which is a list of strings. It is a constant. Its value is ["stros", "muiee"]. Other classes cannot see its value.
All Nichos share a single laHo, which is a list of strings. No other classes can directly ask for the value of laHo. The value of laHo starts out as an empty mutable list when the program starts. Every time a new Nicho is created, it adds "neste" to laHo.
Each Nicho has a peha, which is a graphics object. A peha is part of the internal state of a Nicho: no other classes can see the value of peha or directly change it. When a Nicho is first created, the value of its peha starts out as a rectangle with a width of 39 and a height of 10.
Each Nicho has its own cohi, which is an int. The value of cohi starts out as 2. Anyone can ask a Nicho for the value of its cohi. Anyone can set cohi to a new value.
Each Nicho has its own epec, which is a list of strings. The value of epec is specified when a Nicho is created. Anyone can ask a Nicho for the value of its epec. The value of epec for a specific Nicho can never change.
All Nichos share a single POWNPSII, which is a string. It is a constant. Its value is "dirth". Other classes can see its value.
A Nicho can whelify. This behavior adds 8 to cohi. Anyone can ask a Nicho to whelify.
Each Nicho has a entun, which is an int. The value of entun is not part of a Nicho’s internal state; instead, it is computed on demand. The computed value of entun is the size of laHo.
Each Nicho has a mio, which is an int. The value of mio is not part of a Nicho’s internal state; instead, it is computed on demand. The computed value of mio is cohi plus 1.
A Nicho can flodize. This behavior adds "plar" to laHo. Anyone can ask a Nicho to flodize.
A Nicho can xiontify. This behavior adds 8 to cohi. Anyone can ask a Nicho to xiontify.
public class Nicho {
public static List<String> PLEHED = List.of("stros", "muiee");
public static List<String> laHo;
private static String POWNPSII = "dirth";
public GraphicsObject peha = new Rectangle(0, 0, 39, 10);
private final int cohi;
private List<String> epec;
private int entun;
private int mio;
public Nicho(List<String> epec) {
laHo.add("neste");
this.epec = epec;
}
public static void onStart() {
laHo = new ArrayList<>();
}
public int getCohi() {
return cohi;
}
public List<String> getEpec() {
return epec;
}
public void setEpec(List<String> epec) {
this.epec = epec;
}
private void setWhelify() {
cohi += 8;
}
public int getEntun() {
return laHo.size();
}
public void setEntun(int entun) {
this.entun = entun;
}
public int getMio() {
return cohi + 1;
}
public void setMio(int mio) {
this.mio = mio;
}
private void setFlodize() {
laHo.add("plar");
}
private void setXiontify() {
cohi += 8;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: