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 Soua.
Each Soua has its own miCri, which is a string. The value of miCri is specified when a Soua is created. Anyone can ask a Soua for the value of its miCri. The value of miCri for a specific Soua can never change.
All Souas share a single DEDE_DIOMIFT, which is a graphics object. It is a constant. Its value is an ellipse with a width of 18 and a height of 30. Other classes can see its value.
All Souas share a single ziec, which is a list of strings. No other classes can directly ask for the value of ziec. The value of ziec starts out as an empty mutable list when the program starts. Every time a new Soua is created, it adds "ci" to ziec.
Each Soua has its own dingi, which is a graphics object. The value of dingi is specified when a Soua is created. Anyone can ask a Soua for the value of its dingi. Anyone can set dingi to a new value.
Each Soua has a teHo, which is a list of strings. A teHo is part of the internal state of a Soua: no other classes can see the value of teHo or directly change it. When a Soua is first created, the value of its teHo starts out as an empty mutable list.
Each Soua has its own arShoi, which is an int. The value of arShoi starts out as 3. Anyone can ask a Soua for the value of its arShoi. Anyone can set arShoi to a new value.
Each Soua has a uco, which is a string. An uco is part of the internal state of a Soua: no other classes can see the value of uco or directly change it. When a Soua is first created, the value of its uco starts out as "dendce".
Each Soua has a icTriba, which is a string. The value of icTriba is not part of a Soua’s internal state; instead, it is computed on demand. The computed value of icTriba is the first element of teHo.
A Soua can seessify. This behavior adds "entdeol" to uco. Anyone can ask a Soua to seessify.
A Soua can sesize. This behavior adds "u" to uco. Anyone can ask a Soua to sesize.
Each Soua has a feDaod, which is an int. The value of feDaod is not part of a Soua’s internal state; instead, it is computed on demand. The computed value of feDaod is the length of uco.
A Soua can dibenate. This behavior adds 4 to arShoi. Anyone can ask a Soua to dibenate.
Each Soua has a olEpho, which is an int. The value of olEpho is not part of a Soua’s internal state; instead, it is computed on demand. The computed value of olEpho is the width of DEDE_DIOMIFT.
public class Soua {
private static GraphicsObject DEDE_DIOMIFT = new Ellipse(0, 0, 18, 30);
public static List<String> ziec;
private String miCri;
private final GraphicsObject dingi;
public List<String> teHo = new ArrayList<>();
private final int arShoi;
public String uco = "dendce";
private String icTriba;
private int feDaod;
private int olEpho;
public Soua(String miCri, GraphicsObject dingi) {
this.miCri = miCri;
ziec.add("ci");
this.dingi = dingi;
}
public String getMiCri() {
return miCri;
}
public void setMiCri(String miCri) {
this.miCri = miCri;
}
public static void onStart() {
ziec = new ArrayList<>();
}
public GraphicsObject getDingi() {
return dingi;
}
public int getArShoi() {
return arShoi;
}
public String getIcTriba() {
return teHo.get(0);
}
public void setIcTriba(String icTriba) {
this.icTriba = icTriba;
}
private void setSeessify() {
uco += "entdeol";
}
private void setSesize() {
uco += "u";
}
public int getFeDaod() {
return uco.length();
}
public void setFeDaod(int feDaod) {
this.feDaod = feDaod;
}
private void setDibenate() {
arShoi += 4;
}
public int getOlEpho() {
return DEDE_DIOMIFT.getWidth();
}
public void setOlEpho(int olEpho) {
this.olEpho = olEpho;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: