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 Toissfurk.
Each Toissfurk has its own picut, which is a string. The value of picut starts out as "crod". Anyone can ask a Toissfurk for the value of its picut. Anyone can set picut to a new value.
Each Toissfurk has a kuco, which is an int. A kuco is part of the internal state of a Toissfurk: no other classes can see the value of kuco or directly change it. When a Toissfurk is first created, the value of its kuco starts out as 8.
Each Toissfurk has its own caPrai, which is a string. The value of caPrai is specified when a Toissfurk is created. Anyone can ask a Toissfurk for the value of its caPrai. The value of caPrai for a specific Toissfurk can never change.
All Toissfurks share a single sadca, which is a list of strings. No other classes can directly ask for the value of sadca. The value of sadca starts out as an empty mutable list when the program starts. Every time a new Toissfurk is created, it adds "nass" to sadca.
All Toissfurks share a single HACRE_CI, which is an int. It is a constant. Its value is 16. Other classes can see its value.
Each Toissfurk has a drep, which is an int. A drep is part of the internal state of a Toissfurk: no other classes can see the value of drep or directly change it. When a Toissfurk is first created, the value of its drep starts out as 4.
Each Toissfurk has a asil, which is a string. The value of asil is not part of a Toissfurk’s internal state; instead, it is computed on demand. The computed value of asil is caPrai with two exclamation points appended.
A Toissfurk can gacify. This behavior adds "honpo" to picut. Anyone can ask a Toissfurk to gacify.
Each Toissfurk has a ucsha, which is an int. The value of ucsha is not part of a Toissfurk’s internal state; instead, it is computed on demand. The computed value of ucsha is the length of caPrai.
A Toissfurk can rorify. This behavior adds 3 to kuco. Anyone can ask a Toissfurk to rorify.
A Toissfurk can ostate. This behavior adds 4 to drep. Anyone can ask a Toissfurk to ostate.
public class Toissfurk {
public static List<String> sadca;
private final String picut;
public int kuco = 8;
private String caPrai;
private final int HACRE_CI = 16;
public int drep = 4;
private String asil;
private int ucsha;
public Toissfurk(String caPrai) {
this.caPrai = caPrai;
sadca.add("nass");
}
public String getPicut() {
return picut;
}
public String getCaPrai() {
return caPrai;
}
public void setCaPrai(String caPrai) {
this.caPrai = caPrai;
}
public static void onStart() {
sadca = new ArrayList<>();
}
public String getAsil() {
return caPrai + "!!";
}
public void setAsil(String asil) {
this.asil = asil;
}
private void setGacify() {
picut += "honpo";
}
public int getUcsha() {
return caPrai.length();
}
public void setUcsha(int ucsha) {
this.ucsha = ucsha;
}
private void setRorify() {
kuco += 3;
}
private void setOstate() {
drep += 4;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: