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 Dide.
All Dides share a single ecba, which is a graphics object. No other classes can directly ask for the value of ecba. The value of ecba starts out as a rectangle with a width of 42 and a height of 21 when the program starts. Every time a new Dide is created, it moves ecba to the right by 9 pixels (using the moveBy method).
Each Dide has its own hourd, which is a list of strings. The value of hourd is specified when a Dide is created. Anyone can ask a Dide for the value of its hourd. The value of hourd for a specific Dide can never change.
All Dides share a single AD_PROUN, which is a string. It is a constant. Its value is "menec". Other classes cannot see its value.
Each Dide has a nafo, which is a string. A nafo is part of the internal state of a Dide: no other classes can see the value of nafo or directly change it. When a Dide is first created, the value of its nafo starts out as "a".
Each Dide has its own anEs, which is a graphics object. The value of anEs starts out as a rectangle with a width of 30 and a height of 29. Anyone can ask a Dide for the value of its anEs. Anyone can set anEs to a new value.
Each Dide has its own biDa, which is a string. The value of biDa starts out as "po". Anyone can ask a Dide for the value of its biDa. Anyone can set biDa to a new value.
All Dides share a single ent, which is a string. No other classes can directly ask for the value of ent. The value of ent starts out as "cotso" when the program starts. Every time a new Dide is created, it adds "mul" to ent.
Each Dide has its own pefro, which is a string. The value of pefro is specified when a Dide is created. Anyone can ask a Dide for the value of its pefro. The value of pefro for a specific Dide can never change.
Each Dide has a sor, which is an int. The value of sor is not part of a Dide’s internal state; instead, it is computed on demand. The computed value of sor is the length of pefro.
A Dide can seotify. This behavior moves anEs to the right by 4 pixels (using the moveBy method). Anyone can ask a Dide to seotify.
A Dide can voftify. This behavior adds "ar" to nafo. Anyone can ask a Dide to voftify.
Each Dide has a krari, which is a string. The value of krari is not part of a Dide’s internal state; instead, it is computed on demand. The computed value of krari is pefro with two exclamation points appended.
Each Dide has a prepa, which is a string. The value of prepa is not part of a Dide’s internal state; instead, it is computed on demand. The computed value of prepa is ent with two exclamation points appended.
A Dide can aghtize. This behavior moves ecba to the right by 9 pixels (using the moveBy method). Anyone can ask a Dide to aghtize.
Each Dide has a waven, which is a string. The value of waven is not part of a Dide’s internal state; instead, it is computed on demand. The computed value of waven is ent with two exclamation points appended.
public class Dide {
public static GraphicsObject ecba;
public static String AD_PROUN = "menec";
public static String ent;
private List<String> hourd;
public String nafo = "a";
private final GraphicsObject anEs;
private final String biDa;
private String pefro;
private int sor;
private String krari;
private String prepa;
private String waven;
public Dide(List<String> hourd, String pefro) {
ecba.moveBy(9, 0);
this.hourd = hourd;
ent += "mul";
this.pefro = pefro;
}
public static void onStart() {
ecba = new Rectangle(0, 0, 42, 21);
ent = "cotso";
}
public List<String> getHourd() {
return hourd;
}
public void setHourd(List<String> hourd) {
this.hourd = hourd;
}
public GraphicsObject getAnEs() {
return anEs;
}
public String getBiDa() {
return biDa;
}
public String getPefro() {
return pefro;
}
public void setPefro(String pefro) {
this.pefro = pefro;
}
public int getSor() {
return pefro.length();
}
public void setSor(int sor) {
this.sor = sor;
}
private void setSeotify() {
anEs.moveBy(4, 0);
}
private void setVoftify() {
nafo += "ar";
}
public String getKrari() {
return pefro + "!!";
}
public void setKrari(String krari) {
this.krari = krari;
}
public String getPrepa() {
return ent + "!!";
}
public void setPrepa(String prepa) {
this.prepa = prepa;
}
private void setAghtize() {
ecba.moveBy(9, 0);
}
public String getWaven() {
return ent + "!!";
}
public void setWaven(String waven) {
this.waven = waven;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: