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 Rodseng.
Each Rodseng has its own goe, which is an int. The value of goe starts out as 18. Anyone can ask a Rodseng for the value of its goe. Anyone can set goe to a new value.
All Rodsengs share a single trawe, which is a graphics object. No other classes can directly ask for the value of trawe. The value of trawe starts out as a rectangle with a width of 29 and a height of 38 when the program starts. Every time a new Rodseng is created, it moves trawe to the right by 5 pixels (using the moveBy method).
Each Rodseng has a kiUs, which is a graphics object. A kiUs is part of the internal state of a Rodseng: no other classes can see the value of kiUs or directly change it. When a Rodseng is first created, the value of its kiUs starts out as a rectangle with a width of 33 and a height of 37.
Each Rodseng has its own mePri, which is a list of strings. The value of mePri is specified when a Rodseng is created. Anyone can ask a Rodseng for the value of its mePri. The value of mePri for a specific Rodseng can never change.
All Rodsengs share a single JUSM_IUS, which is a string. It is a constant. Its value is "peposh". Other classes can see its value.
All Rodsengs share a single AR_SINBELP, which is a string. It is a constant. Its value is "foutio". Other classes can see its value.
Each Rodseng has a tiss, which is a string. The value of tiss is not part of a Rodseng’s internal state; instead, it is computed on demand. The computed value of tiss is the first element of mePri.
A Rodseng can edpodize. This behavior moves trawe to the right by 4 pixels (using the moveBy method). Anyone can ask a Rodseng to edpodize.
A Rodseng can kiarolize. This behavior moves kiUs to the right by 2 pixels (using the moveBy method). Anyone can ask a Rodseng to kiarolize.
Each Rodseng has a toXic, which is a string. The value of toXic is not part of a Rodseng’s internal state; instead, it is computed on demand. The computed value of toXic is AR_SINBELP with two exclamation points appended.
Each Rodseng has a seAnpal, which is a string. The value of seAnpal is not part of a Rodseng’s internal state; instead, it is computed on demand. The computed value of seAnpal is AR_SINBELP with two exclamation points appended.
public class Rodseng {
public static GraphicsObject trawe;
private static String JUSM_IUS = "peposh";
private static String AR_SINBELP = "foutio";
private final int goe;
public GraphicsObject kiUs = new Rectangle(0, 0, 33, 37);
private List<String> mePri;
private String tiss;
private String toXic;
private String seAnpal;
public Rodseng(List<String> mePri) {
trawe.moveBy(5, 0);
this.mePri = mePri;
}
public int getGoe() {
return goe;
}
public static void onStart() {
trawe = new Rectangle(0, 0, 29, 38);
}
public List<String> getMePri() {
return mePri;
}
public void setMePri(List<String> mePri) {
this.mePri = mePri;
}
public String getTiss() {
return mePri.get(0);
}
public void setTiss(String tiss) {
this.tiss = tiss;
}
private void setEdpodize() {
trawe.moveBy(4, 0);
}
private void setKiarolize() {
kiUs.moveBy(2, 0);
}
public String getToXic() {
return AR_SINBELP + "!!";
}
public void setToXic(String toXic) {
this.toXic = toXic;
}
public String getSeAnpal() {
return AR_SINBELP + "!!";
}
public void setSeAnpal(String seAnpal) {
this.seAnpal = seAnpal;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: