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 an Ilret.
Each Ilret has a grod, which is a list of strings. A grod is part of the internal state of an Ilret: no other classes can see the value of grod or directly change it. When an Ilret is first created, the value of its grod starts out as an empty mutable list.
All Ilrets share a single siIs, which is a string. No other classes can directly ask for the value of siIs. The value of siIs starts out as "splino" when the program starts. Every time a new Ilret is created, it adds "ectu" to siIs.
All Ilrets share a single SUPREL, which is a list of strings. It is a constant. Its value is ["ciscast", "merfrist", "di"]. Other classes cannot see its value.
Each Ilret has its own piSche, which is a string. The value of piSche starts out as "da". Anyone can ask an Ilret for the value of its piSche. Anyone can set piSche to a new value.
Each Ilret has its own scoo, which is a string. The value of scoo is specified when a Ilret is created. Anyone can ask an Ilret for the value of its scoo. The value of scoo for a specific Ilret can never change.
All Ilrets share a single uthes, which is a string. No other classes can directly ask for the value of uthes. The value of uthes starts out as "ed" when the program starts. Every time a new Ilret is created, it adds "econt" to uthes.
Each Ilret has a galsa, which is an int. A galsa is part of the internal state of an Ilret: no other classes can see the value of galsa or directly change it. When an Ilret is first created, the value of its galsa starts out as 1.
Each Ilret has its own ecLol, which is a string. The value of ecLol is specified when a Ilret is created. Anyone can ask an Ilret for the value of its ecLol. Anyone can set ecLol to a new value.
An Ilret can surcunize. This behavior adds "ri" to siIs. Anyone can ask an Ilret to surcunize.
Each Ilret has a buad, which is a string. The value of buad is not part of an Ilret’s internal state; instead, it is computed on demand. The computed value of buad is siIs with two exclamation points appended.
An Ilret can bemify. This behavior adds "sidar" to piSche. Anyone can ask an Ilret to bemify.
Each Ilret has a baEn, which is an int. The value of baEn is not part of an Ilret’s internal state; instead, it is computed on demand. The computed value of baEn is the length of uthes.
An Ilret can scassate. This behavior adds "peid" to uthes. Anyone can ask an Ilret to scassate.
Each Ilret has a pai, which is an int. The value of pai is not part of an Ilret’s internal state; instead, it is computed on demand. The computed value of pai is the size of grod.
Each Ilret has a zeUnt, which is an int. The value of zeUnt is not part of an Ilret’s internal state; instead, it is computed on demand. The computed value of zeUnt is the length of siIs.
public class Ilret {
public static String siIs;
public static List<String> SUPREL = List.of("ciscast", "merfrist", "di");
public static String uthes;
public List<String> grod = new ArrayList<>();
private final String piSche;
private String scoo;
public int galsa = 1;
private final String ecLol;
private String buad;
private int baEn;
private int pai;
private int zeUnt;
public Ilret(String scoo, String ecLol) {
siIs += "ectu";
this.scoo = scoo;
uthes += "econt";
this.ecLol = ecLol;
}
public static void onStart() {
siIs = "splino";
uthes = "ed";
}
public String getPiSche() {
return piSche;
}
public String getScoo() {
return scoo;
}
public void setScoo(String scoo) {
this.scoo = scoo;
}
public String getEcLol() {
return ecLol;
}
private void setSurcunize() {
siIs += "ri";
}
public String getBuad() {
return siIs + "!!";
}
public void setBuad(String buad) {
this.buad = buad;
}
private void setBemify() {
piSche += "sidar";
}
public int getBaEn() {
return uthes.length();
}
public void setBaEn(int baEn) {
this.baEn = baEn;
}
private void setScassate() {
uthes += "peid";
}
public int getPai() {
return grod.size();
}
public void setPai(int pai) {
this.pai = pai;
}
public int getZeUnt() {
return siIs.length();
}
public void setZeUnt(int zeUnt) {
this.zeUnt = zeUnt;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: