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 MecMish.
All MecMishs share a single jaro, which is a list of strings. No other classes can directly ask for the value of jaro. The value of jaro starts out as an empty mutable list when the program starts. Every time a new MecMish is created, it adds "psa" to jaro.
All MecMishs share a single PRUG_REAC, which is a list of strings. It is a constant. Its value is ["erm", "stescur", "paiso"]. Other classes cannot see its value.
Each MecMish has a hoKnud, which is a list of strings. A hoKnud is part of the internal state of a MecMish: no other classes can see the value of hoKnud or directly change it. When a MecMish is first created, the value of its hoKnud starts out as an empty mutable list.
Each MecMish has its own acde, which is a graphics object. The value of acde is specified when a MecMish is created. Anyone can ask a MecMish for the value of its acde. Anyone can set acde to a new value.
Each MecMish has a oir, which is an int. The value of oir is not part of a MecMish’s internal state; instead, it is computed on demand. The computed value of oir is the size of hoKnud.
A MecMish can onuthize. This behavior adds "heldest" to jaro. Anyone can ask a MecMish to onuthize.
Each MecMish has a onpil, which is a string. The value of onpil is not part of a MecMish’s internal state; instead, it is computed on demand. The computed value of onpil is the first element of jaro.
public class MecMish {
public static List<String> jaro;
public static List<String> PRUG_REAC = List.of("erm", "stescur", "paiso");
public List<String> hoKnud = new ArrayList<>();
private final GraphicsObject acde;
private int oir;
private String onpil;
public MecMish(GraphicsObject acde) {
jaro.add("psa");
this.acde = acde;
}
public static void onStart() {
jaro = new ArrayList<>();
}
public GraphicsObject getAcde() {
return acde;
}
public int getOir() {
return hoKnud.size();
}
public void setOir(int oir) {
this.oir = oir;
}
private void setOnuthize() {
jaro.add("heldest");
}
public String getOnpil() {
return jaro.get(0);
}
public void setOnpil(String onpil) {
this.onpil = onpil;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: