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 Muing.
Each Muing has its own ocsno, which is an int. The value of ocsno is specified when a Muing is created. Anyone can ask a Muing for the value of its ocsno. The value of ocsno for a specific Muing can never change.
All Muings share a single erm, which is a list of strings. No other classes can directly ask for the value of erm. The value of erm starts out as an empty mutable list when the program starts. Every time a new Muing is created, it adds "de" to erm.
All Muings share a single ZI_MOAXT, which is an int. It is a constant. Its value is 5. Other classes cannot see its value.
A Muing can sninify. This behavior adds "slard" to erm. Anyone can ask a Muing to sninify.
Each Muing has a preck, which is an int. The value of preck is not part of a Muing’s internal state; instead, it is computed on demand. The computed value of preck is ocsno squared.
public class Muing {
public static List<String> erm;
private int ocsno;
public final int ZI_MOAXT = 5;
private int preck;
public Muing(int ocsno) {
this.ocsno = ocsno;
erm.add("de");
}
public int getOcsno() {
return ocsno;
}
public void setOcsno(int ocsno) {
this.ocsno = ocsno;
}
public static void onStart() {
erm = new ArrayList<>();
}
private void setSninify() {
erm.add("slard");
}
public int getPreck() {
return ocsno * ocsno;
}
public void setPreck(int preck) {
this.preck = preck;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: