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 Scerlar.
All Scerlars share a single mirun, which is a list of strings. No other classes can directly ask for the value of mirun. The value of mirun starts out as an empty mutable list when the program starts. Every time a new Scerlar is created, it adds "niastsotch" to mirun.
Each Scerlar has a melro, which is an int. A melro is part of the internal state of a Scerlar: no other classes can see the value of melro or directly change it. When a Scerlar is first created, the value of its melro starts out as 9.
Each Scerlar has its own ront, which is a string. The value of ront is specified when a Scerlar is created. Anyone can ask a Scerlar for the value of its ront. Anyone can set ront to a new value.
All Scerlars share a single CRATENG, which is a list of strings. It is a constant. Its value is ["eschlod", "gui"]. Other classes can see its value.
A Scerlar can anmomify. This behavior adds "cusster" to mirun. Anyone can ask a Scerlar to anmomify.
Each Scerlar has a iucu, which is an int. The value of iucu is not part of a Scerlar’s internal state; instead, it is computed on demand. The computed value of iucu is melro squared.
Each Scerlar has a emn, which is an int. The value of emn is not part of a Scerlar’s internal state; instead, it is computed on demand. The computed value of emn is melro plus 1.
public class Scerlar {
public static List<String> mirun;
private static List<String> CRATENG = List.of("eschlod", "gui");
public int melro = 9;
private final String ront;
private int iucu;
private int emn;
public Scerlar(String ront) {
mirun.add("niastsotch");
this.ront = ront;
}
public static void onStart() {
mirun = new ArrayList<>();
}
public String getRont() {
return ront;
}
private void setAnmomify() {
mirun.add("cusster");
}
public int getIucu() {
return melro * melro;
}
public void setIucu(int iucu) {
this.iucu = iucu;
}
public int getEmn() {
return melro + 1;
}
public void setEmn(int emn) {
this.emn = emn;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: