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 Tris.
Each Tris has its own spri, which is an int. The value of spri is specified when a Tris is created. Anyone can ask a Tris for the value of its spri. The value of spri for a specific Tris can never change.
All Triss share a single CLISOO, which is a string. It is a constant. Its value is "cae". Other classes can see its value.
All Triss share a single hesti, which is an int. No other classes can directly ask for the value of hesti. The value of hesti starts out as 15 when the program starts. Every time a new Tris is created, it adds 5 to hesti.
A Tris can scrosize. This behavior adds 6 to hesti. Anyone can ask a Tris to scrosize.
Each Tris has a cron, which is a string. The value of cron is not part of a Tris’s internal state; instead, it is computed on demand. The computed value of cron is CLISOO with two exclamation points appended.
public class Tris {
private static String CLISOO = "cae";
public static int hesti;
private int spri;
private String cron;
public Tris(int spri) {
this.spri = spri;
hesti += 5;
}
public int getSpri() {
return spri;
}
public void setSpri(int spri) {
this.spri = spri;
}
public static void onStart() {
hesti = 15;
}
private void setScrosize() {
hesti += 6;
}
public String getCron() {
return CLISOO + "!!";
}
public void setCron(String cron) {
this.cron = cron;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: