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 Idis.
Each Idis has its own libil, which is a list of strings. The value of libil is specified when a Idis is created. Anyone can ask an Idis for the value of its libil. Anyone can set libil to a new value.
All Idiss share a single afran, which is a graphics object. No other classes can directly ask for the value of afran. The value of afran starts out as a rectangle with a width of 25 and a height of 21 when the program starts. Every time a new Idis is created, it moves afran to the right by 1 pixels (using the moveBy method).
All Idiss share a single GIISMONENG, which is an int. It is a constant. Its value is 2. Other classes can see its value.
Each Idis has a erel, which is an int. The value of erel is not part of an Idis’s internal state; instead, it is computed on demand. The computed value of erel is the width of afran.
An Idis can prenify. This behavior adds "treriung" to libil. Anyone can ask an Idis to prenify.
public class Idis {
public static GraphicsObject afran;
private final List<String> libil;
private final int GI_IS_MONENG = 2;
private int erel;
public Idis(List<String> libil) {
this.libil = libil;
afran.moveBy(1, 0);
}
public List<String> getLibil() {
return libil;
}
public static void onStart() {
afran = new Rectangle(0, 0, 25, 21);
}
public int getErel() {
return afran.getWidth();
}
public void setErel(int erel) {
this.erel = erel;
}
private void setPrenify() {
libil.add("treriung");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: