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 an Eangsche.
Each Eangsche has its own enip, which is an int. The value of enip is specified when a Eangsche is created. Anyone can ask an Eangsche for the value of its enip. The value of enip for a specific Eangsche can never change.
Each Eangsche has its own giaad, which is a list of strings. The value of giaad starts out as an empty mutable list. Anyone can ask an Eangsche for the value of its giaad. Anyone can set giaad to a new value.
All Eangsches share a single iiol, which is a list of strings. No other classes can directly ask for the value of iiol. The value of iiol starts out as an empty mutable list when the program starts. Every time a new Eangsche is created, it adds "aechvoi" to iiol.
All Eangsches share a single APRI_OCCHEG, which is a graphics object. It is a constant. Its value is an ellipse with a width of 37 and a height of 17. Other classes can see its value.
Each Eangsche has a ciuc, which is an int. A ciuc is part of the internal state of an Eangsche: no other classes can see the value of ciuc or directly change it. When an Eangsche is first created, the value of its ciuc starts out as 16.
All Eangsches share a single ashu, which is a graphics object. No other classes can directly ask for the value of ashu. The value of ashu starts out as a rectangle with a width of 20 and a height of 41 when the program starts. Every time a new Eangsche is created, it moves ashu to the right by 4 pixels (using the moveBy method).
An Eangsche can panlenize. This behavior adds "idrin" to iiol. Anyone can ask an Eangsche to panlenize.
Each Eangsche has a ismi, which is an int. The value of ismi is not part of an Eangsche’s internal state; instead, it is computed on demand. The computed value of ismi is the size of giaad.
Each Eangsche has a surco, which is an int. The value of surco is not part of an Eangsche’s internal state; instead, it is computed on demand. The computed value of surco is enip squared.
An Eangsche can sametize. This behavior adds "ja" to iiol. Anyone can ask an Eangsche to sametize.
An Eangsche can surodate. This behavior adds 1 to ciuc. Anyone can ask an Eangsche to surodate.
public class Eangsche {
public static List<String> iiol;
private static GraphicsObject APRI_OCCHEG = new Ellipse(0, 0, 37, 17);
public static GraphicsObject ashu;
private int enip;
private final List<String> giaad;
public int ciuc = 16;
private int ismi;
private int surco;
public Eangsche(int enip) {
this.enip = enip;
iiol.add("aechvoi");
ashu.moveBy(4, 0);
}
public int getEnip() {
return enip;
}
public void setEnip(int enip) {
this.enip = enip;
}
public List<String> getGiaad() {
return giaad;
}
public static void onStart() {
iiol = new ArrayList<>();
ashu = new Rectangle(0, 0, 20, 41);
}
private void setPanlenize() {
iiol.add("idrin");
}
public int getIsmi() {
return giaad.size();
}
public void setIsmi(int ismi) {
this.ismi = ismi;
}
public int getSurco() {
return enip * enip;
}
public void setSurco(int surco) {
this.surco = surco;
}
private void setSametize() {
iiol.add("ja");
}
private void setSurodate() {
ciuc += 1;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: