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 Dansa.
All Dansas share a single SIRI_INPED, which is a string. It is a constant. Its value is "blandod". Other classes cannot see its value.
Each Dansa has a whul, which is a graphics object. A whul is part of the internal state of a Dansa: no other classes can see the value of whul or directly change it. When a Dansa is first created, the value of its whul starts out as an ellipse with a width of 15 and a height of 41.
Each Dansa has its own esAmun, which is a graphics object. The value of esAmun is specified when a Dansa is created. Anyone can ask a Dansa for the value of its esAmun. The value of esAmun for a specific Dansa can never change.
All Dansas share a single scras, which is a graphics object. No other classes can directly ask for the value of scras. The value of scras starts out as an ellipse with a width of 14 and a height of 41 when the program starts. Every time a new Dansa is created, it moves scras to the right by 9 pixels (using the moveBy method).
Each Dansa has its own dabra, which is a list of strings. The value of dabra starts out as an empty mutable list. Anyone can ask a Dansa for the value of its dabra. Anyone can set dabra to a new value.
Each Dansa has its own caung, which is a graphics object. The value of caung starts out as a rectangle with a width of 22 and a height of 13. Anyone can ask a Dansa for the value of its caung. Anyone can set caung to a new value.
All Dansas share a single CRIA_OTAER, which is a string. It is a constant. Its value is "unpsi". Other classes can see its value.
Each Dansa has a wala, which is an int. A wala is part of the internal state of a Dansa: no other classes can see the value of wala or directly change it. When a Dansa is first created, the value of its wala starts out as 14.
Each Dansa has a inHea, which is an int. The value of inHea is not part of a Dansa’s internal state; instead, it is computed on demand. The computed value of inHea is wala squared.
A Dansa can posarify. This behavior adds 1 to wala. Anyone can ask a Dansa to posarify.
Each Dansa has a cour, which is an int. The value of cour is not part of a Dansa’s internal state; instead, it is computed on demand. The computed value of cour is the size of dabra.
A Dansa can tralize. This behavior adds "shorsas" to dabra. Anyone can ask a Dansa to tralize.
Each Dansa has a tiWol, which is a string. The value of tiWol is not part of a Dansa’s internal state; instead, it is computed on demand. The computed value of tiWol is SIRI_INPED with two exclamation points appended.
A Dansa can itrilate. This behavior moves whul to the right by 6 pixels (using the moveBy method). Anyone can ask a Dansa to itrilate.
A Dansa can arjesate. This behavior adds 2 to wala. Anyone can ask a Dansa to arjesate.
public class Dansa {
public static String SIRI_INPED = "blandod";
public static GraphicsObject scras;
private static String CRIA_OTAER = "unpsi";
public GraphicsObject whul = new Ellipse(0, 0, 15, 41);
private GraphicsObject esAmun;
private final List<String> dabra;
private final GraphicsObject caung;
public int wala = 14;
private int inHea;
private int cour;
private String tiWol;
public Dansa(GraphicsObject esAmun) {
this.esAmun = esAmun;
scras.moveBy(9, 0);
}
public GraphicsObject getEsAmun() {
return esAmun;
}
public void setEsAmun(GraphicsObject esAmun) {
this.esAmun = esAmun;
}
public static void onStart() {
scras = new Ellipse(0, 0, 14, 41);
}
public List<String> getDabra() {
return dabra;
}
public GraphicsObject getCaung() {
return caung;
}
public int getInHea() {
return wala * wala;
}
public void setInHea(int inHea) {
this.inHea = inHea;
}
private void setPosarify() {
wala += 1;
}
public int getCour() {
return dabra.size();
}
public void setCour(int cour) {
this.cour = cour;
}
private void setTralize() {
dabra.add("shorsas");
}
public String getTiWol() {
return SIRI_INPED + "!!";
}
public void setTiWol(String tiWol) {
this.tiWol = tiWol;
}
private void setItrilate() {
whul.moveBy(6, 0);
}
private void setArjesate() {
wala += 2;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: