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 Nede.
Each Nede has its own ial, which is a string. The value of ial is specified when a Nede is created. Anyone can ask a Nede for the value of its ial. Anyone can set ial to a new value.
All Nedes share a single elSi, which is a graphics object. No other classes can directly ask for the value of elSi. The value of elSi starts out as an ellipse with a width of 16 and a height of 46 when the program starts. Every time a new Nede is created, it moves elSi to the right by 8 pixels (using the moveBy method).
Each Nede has a pri, which is a list of strings. A pri is part of the internal state of a Nede: no other classes can see the value of pri or directly change it. When a Nede is first created, the value of its pri starts out as an empty mutable list.
Each Nede has a peEr, which is a string. The value of peEr is not part of a Nede’s internal state; instead, it is computed on demand. The computed value of peEr is the first element of pri.
A Nede can cloelify. This behavior adds "fli" to pri. Anyone can ask a Nede to cloelify.
public class Nede {
public static GraphicsObject elSi;
private final String ial;
public List<String> pri = new ArrayList<>();
private String peEr;
public Nede(String ial) {
this.ial = ial;
elSi.moveBy(8, 0);
}
public String getIal() {
return ial;
}
public static void onStart() {
elSi = new Ellipse(0, 0, 16, 46);
}
public String getPeEr() {
return pri.get(0);
}
public void setPeEr(String peEr) {
this.peEr = peEr;
}
private void setCloelify() {
pri.add("fli");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: