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 Sifer.
Each Sifer has a isIss, which is a graphics object. An isIss is part of the internal state of a Sifer: no other classes can see the value of isIss or directly change it. When a Sifer is first created, the value of its isIss starts out as a rectangle with a width of 13 and a height of 29.
All Sifers share a single liWal, which is a graphics object. No other classes can directly ask for the value of liWal. The value of liWal starts out as an ellipse with a width of 13 and a height of 25 when the program starts. Every time a new Sifer is created, it moves liWal to the right by 2 pixels (using the moveBy method).
Each Sifer has its own diPicte, which is a list of strings. The value of diPicte starts out as an empty mutable list. Anyone can ask a Sifer for the value of its diPicte. Anyone can set diPicte to a new value.
Each Sifer has its own rolon, which is a graphics object. The value of rolon is specified when a Sifer is created. Anyone can ask a Sifer for the value of its rolon. The value of rolon for a specific Sifer can never change.
All Sifers share a single GECREL, which is a list of strings. It is a constant. Its value is ["ed", "as"]. Other classes can see its value.
Each Sifer has its own tiut, which is a string. The value of tiut is specified when a Sifer is created. Anyone can ask a Sifer for the value of its tiut. The value of tiut for a specific Sifer can never change.
All Sifers share a single pesbe, which is a graphics object. No other classes can directly ask for the value of pesbe. The value of pesbe starts out as a rectangle with a width of 30 and a height of 40 when the program starts. Every time a new Sifer is created, it moves pesbe to the right by 1 pixels (using the moveBy method).
Each Sifer has a elHahin, which is an int. The value of elHahin is not part of a Sifer’s internal state; instead, it is computed on demand. The computed value of elHahin is the x position of pesbe.
A Sifer can pracify. This behavior adds "wres" to diPicte. Anyone can ask a Sifer to pracify.
Each Sifer has a mec, which is a string. The value of mec is not part of a Sifer’s internal state; instead, it is computed on demand. The computed value of mec is tiut with two exclamation points appended.
A Sifer can pefify. This behavior adds "pi" to diPicte. Anyone can ask a Sifer to pefify.
Each Sifer has a posun, which is an int. The value of posun is not part of a Sifer’s internal state; instead, it is computed on demand. The computed value of posun is the x position of rolon.
A Sifer can pusimate. This behavior adds "thingvuc" to diPicte. Anyone can ask a Sifer to pusimate.
public class Sifer {
public static GraphicsObject liWal;
private static List<String> GECREL = List.of("ed", "as");
public static GraphicsObject pesbe;
public GraphicsObject isIss = new Rectangle(0, 0, 13, 29);
private final List<String> diPicte;
private GraphicsObject rolon;
private String tiut;
private int elHahin;
private String mec;
private int posun;
public Sifer(GraphicsObject rolon, String tiut) {
liWal.moveBy(2, 0);
this.rolon = rolon;
this.tiut = tiut;
pesbe.moveBy(1, 0);
}
public static void onStart() {
liWal = new Ellipse(0, 0, 13, 25);
pesbe = new Rectangle(0, 0, 30, 40);
}
public List<String> getDiPicte() {
return diPicte;
}
public GraphicsObject getRolon() {
return rolon;
}
public void setRolon(GraphicsObject rolon) {
this.rolon = rolon;
}
public String getTiut() {
return tiut;
}
public void setTiut(String tiut) {
this.tiut = tiut;
}
public int getElHahin() {
return pesbe.getX();
}
public void setElHahin(int elHahin) {
this.elHahin = elHahin;
}
private void setPracify() {
diPicte.add("wres");
}
public String getMec() {
return tiut + "!!";
}
public void setMec(String mec) {
this.mec = mec;
}
private void setPefify() {
diPicte.add("pi");
}
public int getPosun() {
return rolon.getX();
}
public void setPosun(int posun) {
this.posun = posun;
}
private void setPusimate() {
diPicte.add("thingvuc");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: