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 Mafas.
All Mafass share a single TAHARD, which is a list of strings. It is a constant. Its value is ["kosskrel", "um"]. Other classes can see its value.
Each Mafas has its own urNont, which is a string. The value of urNont is specified when a Mafas is created. Anyone can ask a Mafas for the value of its urNont. The value of urNont for a specific Mafas can never change.
All Mafass share a single pri, which is a list of strings. No other classes can directly ask for the value of pri. The value of pri starts out as an empty mutable list when the program starts. Every time a new Mafas is created, it adds "snavul" to pri.
Each Mafas has its own duSplor, which is a graphics object. The value of duSplor starts out as a rectangle with a width of 48 and a height of 38. Anyone can ask a Mafas for the value of its duSplor. Anyone can set duSplor to a new value.
Each Mafas has a vuss, which is a list of strings. A vuss is part of the internal state of a Mafas: no other classes can see the value of vuss or directly change it. When a Mafas is first created, the value of its vuss starts out as an empty mutable list.
A Mafas can cisonize. This behavior adds "asszun" to vuss. Anyone can ask a Mafas to cisonize.
Each Mafas has a mecir, which is an int. The value of mecir is not part of a Mafas’s internal state; instead, it is computed on demand. The computed value of mecir is the size of pri.
Each Mafas has a peti, which is an int. The value of peti is not part of a Mafas’s internal state; instead, it is computed on demand. The computed value of peti is the size of TAHARD.
A Mafas can girate. This behavior moves duSplor to the right by 8 pixels (using the moveBy method). Anyone can ask a Mafas to girate.
public class Mafas {
private static List<String> TAHARD = List.of("kosskrel", "um");
public static List<String> pri;
private String urNont;
private final GraphicsObject duSplor;
public List<String> vuss = new ArrayList<>();
private int mecir;
private int peti;
public Mafas(String urNont) {
this.urNont = urNont;
pri.add("snavul");
}
public String getUrNont() {
return urNont;
}
public void setUrNont(String urNont) {
this.urNont = urNont;
}
public static void onStart() {
pri = new ArrayList<>();
}
public GraphicsObject getDuSplor() {
return duSplor;
}
private void setCisonize() {
vuss.add("asszun");
}
public int getMecir() {
return pri.size();
}
public void setMecir(int mecir) {
this.mecir = mecir;
}
public int getPeti() {
return TAHARD.size();
}
public void setPeti(int peti) {
this.peti = peti;
}
private void setGirate() {
duSplor.moveBy(8, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: