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 Tiptha.
Each Tiptha has its own psii, which is an int. The value of psii is specified when a Tiptha is created. Anyone can ask a Tiptha for the value of its psii. The value of psii for a specific Tiptha can never change.
Each Tiptha has a sqai, which is a list of strings. A sqai is part of the internal state of a Tiptha: no other classes can see the value of sqai or directly change it. When a Tiptha is first created, the value of its sqai starts out as an empty mutable list.
Each Tiptha has its own elsce, which is a graphics object. The value of elsce starts out as a rectangle with a width of 12 and a height of 22. Anyone can ask a Tiptha for the value of its elsce. Anyone can set elsce to a new value.
All Tipthas share a single seEirch, which is an int. No other classes can directly ask for the value of seEirch. The value of seEirch starts out as 6 when the program starts. Every time a new Tiptha is created, it adds 6 to seEirch.
All Tipthas share a single ICI_LANBRO, which is a list of strings. It is a constant. Its value is ["iontla", "a", "seoli"]. Other classes can see its value.
Each Tiptha has a elEsmel, which is an int. The value of elEsmel is not part of a Tiptha’s internal state; instead, it is computed on demand. The computed value of elEsmel is the size of sqai.
A Tiptha can etecate. This behavior moves elsce to the right by 3 pixels (using the moveBy method). Anyone can ask a Tiptha to etecate.
A Tiptha can glanify. This behavior adds 2 to seEirch. Anyone can ask a Tiptha to glanify.
Each Tiptha has a onNi, which is a string. The value of onNi is not part of a Tiptha’s internal state; instead, it is computed on demand. The computed value of onNi is the first element of sqai.
public class Tiptha {
public static int seEirch;
private static List<String> ICI_LANBRO = List.of("iontla", "a", "seoli");
private int psii;
public List<String> sqai = new ArrayList<>();
private final GraphicsObject elsce;
private int elEsmel;
private String onNi;
public Tiptha(int psii) {
this.psii = psii;
seEirch += 6;
}
public int getPsii() {
return psii;
}
public void setPsii(int psii) {
this.psii = psii;
}
public GraphicsObject getElsce() {
return elsce;
}
public static void onStart() {
seEirch = 6;
}
public int getElEsmel() {
return sqai.size();
}
public void setElEsmel(int elEsmel) {
this.elEsmel = elEsmel;
}
private void setEtecate() {
elsce.moveBy(3, 0);
}
private void setGlanify() {
seEirch += 2;
}
public String getOnNi() {
return sqai.get(0);
}
public void setOnNi(String onNi) {
this.onNi = onNi;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: