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 Mudal.
All Mudals share a single ERDIN_TRANMEC, which is an int. It is a constant. Its value is 18. Other classes cannot see its value.
Each Mudal has its own vit, which is a graphics object. The value of vit is specified when a Mudal is created. Anyone can ask a Mudal for the value of its vit. The value of vit for a specific Mudal can never change.
Each Mudal has a seFrar, which is a list of strings. A seFrar is part of the internal state of a Mudal: no other classes can see the value of seFrar or directly change it. When a Mudal is first created, the value of its seFrar starts out as an empty mutable list.
Each Mudal has a pri, which is a string. The value of pri is not part of a Mudal’s internal state; instead, it is computed on demand. The computed value of pri is the first element of seFrar.
A Mudal can scangify. This behavior adds "crar" to seFrar. Anyone can ask a Mudal to scangify.
public class Mudal {
public final int ERDIN_TRANMEC = 18;
private GraphicsObject vit;
public List<String> seFrar = new ArrayList<>();
private String pri;
public Mudal(GraphicsObject vit) {
this.vit = vit;
}
public GraphicsObject getVit() {
return vit;
}
public void setVit(GraphicsObject vit) {
this.vit = vit;
}
public String getPri() {
return seFrar.get(0);
}
public void setPri(String pri) {
this.pri = pri;
}
private void setScangify() {
seFrar.add("crar");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: