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 TroSipspar.
All TroSipspars share a single amcon, which is a graphics object. No other classes can directly ask for the value of amcon. The value of amcon starts out as a rectangle with a width of 32 and a height of 21 when the program starts. Every time a new TroSipspar is created, it moves amcon to the right by 1 pixels (using the moveBy method).
Each TroSipspar has a deSqoc, which is a graphics object. A deSqoc is part of the internal state of a TroSipspar: no other classes can see the value of deSqoc or directly change it. When a TroSipspar is first created, the value of its deSqoc starts out as a rectangle with a width of 46 and a height of 23.
Each TroSipspar has its own cioea, which is a graphics object. The value of cioea starts out as a rectangle with a width of 14 and a height of 28. Anyone can ask a TroSipspar for the value of its cioea. Anyone can set cioea to a new value.
All TroSipspars share a single JENG_ES, which is a list of strings. It is a constant. Its value is ["iobi", "hacpiar", "ral"]. Other classes can see its value.
A TroSipspar can diiditize. This behavior moves deSqoc to the right by 7 pixels (using the moveBy method). Anyone can ask a TroSipspar to diiditize.
Each TroSipspar has a psel, which is an int. The value of psel is not part of a TroSipspar’s internal state; instead, it is computed on demand. The computed value of psel is the width of amcon.
A TroSipspar can dedonize. This behavior moves deSqoc to the right by 4 pixels (using the moveBy method). Anyone can ask a TroSipspar to dedonize.
public class TroSipspar {
public static GraphicsObject amcon;
private static List<String> JENG_ES = List.of("iobi", "hacpiar", "ral");
public GraphicsObject deSqoc = new Rectangle(0, 0, 46, 23);
private final GraphicsObject cioea;
private int psel;
public TroSipspar() {
amcon.moveBy(1, 0);
}
public static void onStart() {
amcon = new Rectangle(0, 0, 32, 21);
}
public GraphicsObject getCioea() {
return cioea;
}
private void setDiiditize() {
deSqoc.moveBy(7, 0);
}
public int getPsel() {
return amcon.getWidth();
}
public void setPsel(int psel) {
this.psel = psel;
}
private void setDedonize() {
deSqoc.moveBy(4, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: