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 Engsto.
Each Engsto has its own maAgi, which is a string. The value of maAgi is specified when a Engsto is created. Anyone can ask an Engsto for the value of its maAgi. The value of maAgi for a specific Engsto can never change.
All Engstos share a single osche, which is a list of strings. No other classes can directly ask for the value of osche. The value of osche starts out as an empty mutable list when the program starts. Every time a new Engsto is created, it adds "trol" to osche.
Each Engsto has a ipiss, which is a string. An ipiss is part of the internal state of an Engsto: no other classes can see the value of ipiss or directly change it. When an Engsto is first created, the value of its ipiss starts out as "hanpre".
Each Engsto has its own darem, which is an int. The value of darem starts out as 10. Anyone can ask an Engsto for the value of its darem. Anyone can set darem to a new value.
All Engstos share a single MUCAIC, which is an int. It is a constant. Its value is 19. Other classes can see its value.
Each Engsto has its own tioje, which is a string. The value of tioje starts out as "lal". Anyone can ask an Engsto for the value of its tioje. Anyone can set tioje to a new value.
All Engstos share a single IO_PSISTU, which is a string. It is a constant. Its value is "ninar". Other classes cannot see its value.
An Engsto can pratize. This behavior adds "soung" to osche. Anyone can ask an Engsto to pratize.
Each Engsto has a noni, which is an int. The value of noni is not part of an Engsto’s internal state; instead, it is computed on demand. The computed value of noni is MUCAIC squared.
An Engsto can iollify. This behavior adds "nio" to tioje. Anyone can ask an Engsto to iollify.
Each Engsto has a duoin, which is an int. The value of duoin is not part of an Engsto’s internal state; instead, it is computed on demand. The computed value of duoin is darem squared.
An Engsto can tesate. This behavior adds "toickdont" to tioje. Anyone can ask an Engsto to tesate.
Each Engsto has a ilBolp, which is an int. The value of ilBolp is not part of an Engsto’s internal state; instead, it is computed on demand. The computed value of ilBolp is the length of tioje.
public class Engsto {
public static List<String> osche;
public static String IO_PSISTU = "ninar";
private String maAgi;
public String ipiss = "hanpre";
private final int darem;
private final int MUCAIC = 19;
private final String tioje;
private int noni;
private int duoin;
private int ilBolp;
public Engsto(String maAgi) {
this.maAgi = maAgi;
osche.add("trol");
}
public String getMaAgi() {
return maAgi;
}
public void setMaAgi(String maAgi) {
this.maAgi = maAgi;
}
public static void onStart() {
osche = new ArrayList<>();
}
public int getDarem() {
return darem;
}
public String getTioje() {
return tioje;
}
private void setPratize() {
osche.add("soung");
}
public int getNoni() {
return MUCAIC * MUCAIC;
}
public void setNoni(int noni) {
this.noni = noni;
}
private void setIollify() {
tioje += "nio";
}
public int getDuoin() {
return darem * darem;
}
public void setDuoin(int duoin) {
this.duoin = duoin;
}
private void setTesate() {
tioje += "toickdont";
}
public int getIlBolp() {
return tioje.length();
}
public void setIlBolp(int ilBolp) {
this.ilBolp = ilBolp;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: