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 Sace.
All Saces share a single ZOFAL_EN, which is a string. It is a constant. Its value is "perg". Other classes cannot see its value.
Each Sace has a lae, which is a list of strings. A lae is part of the internal state of a Sace: no other classes can see the value of lae or directly change it. When a Sace is first created, the value of its lae starts out as an empty mutable list.
All Saces share a single sutch, which is an int. No other classes can directly ask for the value of sutch. The value of sutch starts out as 17 when the program starts. Every time a new Sace is created, it adds 4 to sutch.
Each Sace has its own ecUs, which is an int. The value of ecUs is specified when a Sace is created. Anyone can ask a Sace for the value of its ecUs. The value of ecUs for a specific Sace can never change.
Each Sace has its own kah, which is a graphics object. The value of kah starts out as an ellipse with a width of 21 and a height of 37. Anyone can ask a Sace for the value of its kah. Anyone can set kah to a new value.
A Sace can iolify. This behavior adds "pras" to lae. Anyone can ask a Sace to iolify.
Each Sace has a aestu, which is an int. The value of aestu is not part of a Sace’s internal state; instead, it is computed on demand. The computed value of aestu is the size of lae.
A Sace can dratize. This behavior adds 9 to sutch. Anyone can ask a Sace to dratize.
Each Sace has a caDi, which is an int. The value of caDi is not part of a Sace’s internal state; instead, it is computed on demand. The computed value of caDi is sutch plus 4.
public class Sace {
public static String ZOFAL_EN = "perg";
public static int sutch;
public List<String> lae = new ArrayList<>();
private int ecUs;
private final GraphicsObject kah;
private int aestu;
private int caDi;
public Sace(int ecUs) {
sutch += 4;
this.ecUs = ecUs;
}
public static void onStart() {
sutch = 17;
}
public int getEcUs() {
return ecUs;
}
public void setEcUs(int ecUs) {
this.ecUs = ecUs;
}
public GraphicsObject getKah() {
return kah;
}
private void setIolify() {
lae.add("pras");
}
public int getAestu() {
return lae.size();
}
public void setAestu(int aestu) {
this.aestu = aestu;
}
private void setDratize() {
sutch += 9;
}
public int getCaDi() {
return sutch + 4;
}
public void setCaDi(int caDi) {
this.caDi = caDi;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: