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 Splel.
Each Splel has its own onVu, which is a list of strings. The value of onVu is specified when a Splel is created. Anyone can ask a Splel for the value of its onVu. The value of onVu for a specific Splel can never change.
All Splels share a single presm, which is a list of strings. No other classes can directly ask for the value of presm. The value of presm starts out as an empty mutable list when the program starts. Every time a new Splel is created, it adds "asm" to presm.
All Splels share a single CERDPRO, which is a graphics object. It is a constant. Its value is a rectangle with a width of 12 and a height of 39. Other classes cannot see its value.
A Splel can cilsunate. This behavior adds "heemmad" to presm. Anyone can ask a Splel to cilsunate.
Each Splel has a gloum, which is a string. The value of gloum is not part of a Splel’s internal state; instead, it is computed on demand. The computed value of gloum is the first element of onVu.
public class Splel {
public static List<String> presm;
public static GraphicsObject CERDPRO = new Rectangle(0, 0, 12, 39);
private List<String> onVu;
private String gloum;
public Splel(List<String> onVu) {
this.onVu = onVu;
presm.add("asm");
}
public List<String> getOnVu() {
return onVu;
}
public void setOnVu(List<String> onVu) {
this.onVu = onVu;
}
public static void onStart() {
presm = new ArrayList<>();
}
private void setCilsunate() {
presm.add("heemmad");
}
public String getGloum() {
return onVu.get(0);
}
public void setGloum(String gloum) {
this.gloum = gloum;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: