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 Cuntdri.
Each Cuntdri has a alid, which is an int. An alid is part of the internal state of a Cuntdri: no other classes can see the value of alid or directly change it. When a Cuntdri is first created, the value of its alid starts out as 7.
All Cuntdris share a single stist, which is a list of strings. No other classes can directly ask for the value of stist. The value of stist starts out as an empty mutable list when the program starts. Every time a new Cuntdri is created, it adds "erorn" to stist.
All Cuntdris share a single OL_WORAD, which is an int. It is a constant. Its value is 18. Other classes can see its value.
Each Cuntdri has its own taRa, which is a list of strings. The value of taRa starts out as an empty mutable list. Anyone can ask a Cuntdri for the value of its taRa. Anyone can set taRa to a new value.
A Cuntdri can olsilify. This behavior adds "dodol" to taRa. Anyone can ask a Cuntdri to olsilify.
Each Cuntdri has a chel, which is a string. The value of chel is not part of a Cuntdri’s internal state; instead, it is computed on demand. The computed value of chel is the first element of taRa.
A Cuntdri can scaulify. This behavior adds 2 to alid. Anyone can ask a Cuntdri to scaulify.
public class Cuntdri {
public static List<String> stist;
public int alid = 7;
private final int OL_WORAD = 18;
private final List<String> taRa;
private String chel;
public Cuntdri() {
stist.add("erorn");
}
public static void onStart() {
stist = new ArrayList<>();
}
public List<String> getTaRa() {
return taRa;
}
private void setOlsilify() {
taRa.add("dodol");
}
public String getChel() {
return taRa.get(0);
}
public void setChel(String chel) {
this.chel = chel;
}
private void setScaulify() {
alid += 2;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: