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 Senpal.
Each Senpal has its own pra, which is an int. The value of pra is specified when a Senpal is created. Anyone can ask a Senpal for the value of its pra. The value of pra for a specific Senpal can never change.
All Senpals share a single moCi, which is an int. No other classes can directly ask for the value of moCi. The value of moCi starts out as 15 when the program starts. Every time a new Senpal is created, it adds 2 to moCi.
Each Senpal has its own tro, which is a list of strings. The value of tro starts out as an empty mutable list. Anyone can ask a Senpal for the value of its tro. Anyone can set tro to a new value.
Each Senpal has a buse, which is a string. A buse is part of the internal state of a Senpal: no other classes can see the value of buse or directly change it. When a Senpal is first created, the value of its buse starts out as "ucea".
All Senpals share a single ROLUBRACI, which is a list of strings. It is a constant. Its value is ["so", "ue", "dosme"]. Other classes can see its value.
Each Senpal has its own tiho, which is a graphics object. The value of tiho starts out as a rectangle with a width of 30 and a height of 47. Anyone can ask a Senpal for the value of its tiho. Anyone can set tiho to a new value.
All Senpals share a single GECCORD, which is an int. It is a constant. Its value is 18. Other classes can see its value.
Each Senpal has a osa, which is an int. The value of osa is not part of a Senpal’s internal state; instead, it is computed on demand. The computed value of osa is moCi plus 5.
A Senpal can nentize. This behavior moves tiho to the right by 8 pixels (using the moveBy method). Anyone can ask a Senpal to nentize.
Each Senpal has a mePhe, which is an int. The value of mePhe is not part of a Senpal’s internal state; instead, it is computed on demand. The computed value of mePhe is GECCORD plus 2.
A Senpal can hertonize. This behavior adds "ordish" to buse. Anyone can ask a Senpal to hertonize.
A Senpal can tonasify. This behavior adds "smir" to buse. Anyone can ask a Senpal to tonasify.
Each Senpal has a osec, which is an int. The value of osec is not part of a Senpal’s internal state; instead, it is computed on demand. The computed value of osec is moCi plus 1.
public class Senpal {
public static int moCi;
private static List<String> RO_LU_BRACI = List.of("so", "ue", "dosme");
private int pra;
private final List<String> tro;
public String buse = "ucea";
private final GraphicsObject tiho;
private final int GECCORD = 18;
private int osa;
private int mePhe;
private int osec;
public Senpal(int pra) {
this.pra = pra;
moCi += 2;
}
public int getPra() {
return pra;
}
public void setPra(int pra) {
this.pra = pra;
}
public static void onStart() {
moCi = 15;
}
public List<String> getTro() {
return tro;
}
public GraphicsObject getTiho() {
return tiho;
}
public int getOsa() {
return moCi + 5;
}
public void setOsa(int osa) {
this.osa = osa;
}
private void setNentize() {
tiho.moveBy(8, 0);
}
public int getMePhe() {
return GECCORD + 2;
}
public void setMePhe(int mePhe) {
this.mePhe = mePhe;
}
private void setHertonize() {
buse += "ordish";
}
private void setTonasify() {
buse += "smir";
}
public int getOsec() {
return moCi + 1;
}
public void setOsec(int osec) {
this.osec = osec;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: