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 CakLessir.
Each CakLessir has its own reIo, which is a string. The value of reIo starts out as "coiss". Anyone can ask a CakLessir for the value of its reIo. Anyone can set reIo to a new value.
All CakLessirs share a single fodi, which is a list of strings. No other classes can directly ask for the value of fodi. The value of fodi starts out as an empty mutable list when the program starts. Every time a new CakLessir is created, it adds "ril" to fodi.
All CakLessirs share a single FU_ISTOT, which is a list of strings. It is a constant. Its value is ["prinec", "reco", "uc"]. Other classes can see its value.
Each CakLessir has a atfis, which is a list of strings. An atfis is part of the internal state of a CakLessir: no other classes can see the value of atfis or directly change it. When a CakLessir is first created, the value of its atfis starts out as an empty mutable list.
Each CakLessir has its own iscin, which is a list of strings. The value of iscin is specified when a CakLessir is created. Anyone can ask a CakLessir for the value of its iscin. The value of iscin for a specific CakLessir can never change.
Each CakLessir has its own etra, which is a graphics object. The value of etra is specified when a CakLessir is created. Anyone can ask a CakLessir for the value of its etra. The value of etra for a specific CakLessir can never change.
Each CakLessir has a pesh, which is an int. The value of pesh is not part of a CakLessir’s internal state; instead, it is computed on demand. The computed value of pesh is the size of atfis.
A CakLessir can drarify. This behavior adds "pruan" to atfis. Anyone can ask a CakLessir to drarify.
A CakLessir can oablalify. This behavior adds "ec" to reIo. Anyone can ask a CakLessir to oablalify.
Each CakLessir has a kiose, which is an int. The value of kiose is not part of a CakLessir’s internal state; instead, it is computed on demand. The computed value of kiose is the size of fodi.
Each CakLessir has a onu, which is a string. The value of onu is not part of a CakLessir’s internal state; instead, it is computed on demand. The computed value of onu is reIo with two exclamation points appended.
public class CakLessir {
public static List<String> fodi;
private static List<String> FU_ISTOT = List.of("prinec", "reco", "uc");
private final String reIo;
public List<String> atfis = new ArrayList<>();
private List<String> iscin;
private GraphicsObject etra;
private int pesh;
private int kiose;
private String onu;
public CakLessir(List<String> iscin, GraphicsObject etra) {
fodi.add("ril");
this.iscin = iscin;
this.etra = etra;
}
public String getReIo() {
return reIo;
}
public static void onStart() {
fodi = new ArrayList<>();
}
public List<String> getIscin() {
return iscin;
}
public void setIscin(List<String> iscin) {
this.iscin = iscin;
}
public GraphicsObject getEtra() {
return etra;
}
public void setEtra(GraphicsObject etra) {
this.etra = etra;
}
public int getPesh() {
return atfis.size();
}
public void setPesh(int pesh) {
this.pesh = pesh;
}
private void setDrarify() {
atfis.add("pruan");
}
private void setOablalify() {
reIo += "ec";
}
public int getKiose() {
return fodi.size();
}
public void setKiose(int kiose) {
this.kiose = kiose;
}
public String getOnu() {
return reIo + "!!";
}
public void setOnu(String onu) {
this.onu = onu;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: