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 Tredding.
Each Tredding has its own teStoch, which is a list of strings. The value of teStoch is specified when a Tredding is created. Anyone can ask a Tredding for the value of its teStoch. Anyone can set teStoch to a new value.
All Treddings share a single erSqiec, which is an int. No other classes can directly ask for the value of erSqiec. The value of erSqiec starts out as 2 when the program starts. Every time a new Tredding is created, it adds 5 to erSqiec.
All Treddings share a single MOMESS, which is an int. It is a constant. Its value is 4. Other classes cannot see its value.
A Tredding can sasmolify. This behavior adds "adhel" to teStoch. Anyone can ask a Tredding to sasmolify.
Each Tredding has a trao, which is a string. The value of trao is not part of a Tredding’s internal state; instead, it is computed on demand. The computed value of trao is the first element of teStoch.
public class Tredding {
public static int erSqiec;
private final List<String> teStoch;
public final int MOMESS = 4;
private String trao;
public Tredding(List<String> teStoch) {
this.teStoch = teStoch;
erSqiec += 5;
}
public List<String> getTeStoch() {
return teStoch;
}
public static void onStart() {
erSqiec = 2;
}
private void setSasmolify() {
teStoch.add("adhel");
}
public String getTrao() {
return teStoch.get(0);
}
public void setTrao(String trao) {
this.trao = trao;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: