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 Prerd.
All Prerds share a single feNec, which is a graphics object. No other classes can directly ask for the value of feNec. The value of feNec starts out as an ellipse with a width of 21 and a height of 22 when the program starts. Every time a new Prerd is created, it moves feNec to the right by 8 pixels (using the moveBy method).
All Prerds share a single FRELGLE, which is a list of strings. It is a constant. Its value is ["bouci", "fep", "luchol"]. Other classes can see its value.
Each Prerd has a iltra, which is an int. An iltra is part of the internal state of a Prerd: no other classes can see the value of iltra or directly change it. When a Prerd is first created, the value of its iltra starts out as 2.
Each Prerd has its own pocne, which is a string. The value of pocne starts out as "gangu". Anyone can ask a Prerd for the value of its pocne. Anyone can set pocne to a new value.
Each Prerd has its own prouc, which is an int. The value of prouc is specified when a Prerd is created. Anyone can ask a Prerd for the value of its prouc. The value of prouc for a specific Prerd can never change.
Each Prerd has a cema, which is an int. The value of cema is not part of a Prerd’s internal state; instead, it is computed on demand. The computed value of cema is iltra plus 8.
A Prerd can coalize. This behavior adds "eend" to pocne. Anyone can ask a Prerd to coalize.
Each Prerd has a umOn, which is an int. The value of umOn is not part of a Prerd’s internal state; instead, it is computed on demand. The computed value of umOn is iltra squared.
A Prerd can gusilize. This behavior adds "platrhi" to pocne. Anyone can ask a Prerd to gusilize.
public class Prerd {
public static GraphicsObject feNec;
private static List<String> FRELGLE = List.of("bouci", "fep", "luchol");
public int iltra = 2;
private final String pocne;
private int prouc;
private int cema;
private int umOn;
public Prerd(int prouc) {
feNec.moveBy(8, 0);
this.prouc = prouc;
}
public static void onStart() {
feNec = new Ellipse(0, 0, 21, 22);
}
public String getPocne() {
return pocne;
}
public int getProuc() {
return prouc;
}
public void setProuc(int prouc) {
this.prouc = prouc;
}
public int getCema() {
return iltra + 8;
}
public void setCema(int cema) {
this.cema = cema;
}
private void setCoalize() {
pocne += "eend";
}
public int getUmOn() {
return iltra * iltra;
}
public void setUmOn(int umOn) {
this.umOn = umOn;
}
private void setGusilize() {
pocne += "platrhi";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: