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 Rouss.
All Rousss share a single PHUSTWIT, which is a list of strings. It is a constant. Its value is ["sueshwia", "glilcen"]. Other classes can see its value.
Each Rouss has its own pric, which is a string. The value of pric is specified when a Rouss is created. Anyone can ask a Rouss for the value of its pric. The value of pric for a specific Rouss can never change.
Each Rouss has its own ocil, which is a list of strings. The value of ocil starts out as an empty mutable list. Anyone can ask a Rouss for the value of its ocil. Anyone can set ocil to a new value.
Each Rouss has a hoCu, which is an int. A hoCu is part of the internal state of a Rouss: no other classes can see the value of hoCu or directly change it. When a Rouss is first created, the value of its hoCu starts out as 13.
All Rousss share a single tac, which is a graphics object. No other classes can directly ask for the value of tac. The value of tac starts out as a rectangle with a width of 43 and a height of 31 when the program starts. Every time a new Rouss is created, it moves tac to the right by 3 pixels (using the moveBy method).
A Rouss can etinate. This behavior adds "mowdram" to ocil. Anyone can ask a Rouss to etinate.
Each Rouss has a lidmi, which is an int. The value of lidmi is not part of a Rouss’s internal state; instead, it is computed on demand. The computed value of lidmi is the length of pric.
Each Rouss has a moni, which is a string. The value of moni is not part of a Rouss’s internal state; instead, it is computed on demand. The computed value of moni is the first element of ocil.
A Rouss can ussize. This behavior moves tac to the right by 3 pixels (using the moveBy method). Anyone can ask a Rouss to ussize.
public class Rouss {
private static List<String> PHUSTWIT = List.of("sueshwia", "glilcen");
public static GraphicsObject tac;
private String pric;
private final List<String> ocil;
public int hoCu = 13;
private int lidmi;
private String moni;
public Rouss(String pric) {
this.pric = pric;
tac.moveBy(3, 0);
}
public String getPric() {
return pric;
}
public void setPric(String pric) {
this.pric = pric;
}
public List<String> getOcil() {
return ocil;
}
public static void onStart() {
tac = new Rectangle(0, 0, 43, 31);
}
private void setEtinate() {
ocil.add("mowdram");
}
public int getLidmi() {
return pric.length();
}
public void setLidmi(int lidmi) {
this.lidmi = lidmi;
}
public String getMoni() {
return ocil.get(0);
}
public void setMoni(String moni) {
this.moni = moni;
}
private void setUssize() {
tac.moveBy(3, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: