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 Cleu.
Each Cleu has its own prer, which is an int. The value of prer is specified when a Cleu is created. Anyone can ask a Cleu for the value of its prer. The value of prer for a specific Cleu can never change.
All Cleus share a single RE_PHUN, which is a list of strings. It is a constant. Its value is ["wor", "nanlioc", "asi"]. Other classes cannot see its value.
All Cleus share a single beb, which is a string. No other classes can directly ask for the value of beb. The value of beb starts out as "eno" when the program starts. Every time a new Cleu is created, it adds "cerdoint" to beb.
Each Cleu has its own edDoirf, which is an int. The value of edDoirf is specified when a Cleu is created. Anyone can ask a Cleu for the value of its edDoirf. Anyone can set edDoirf to a new value.
Each Cleu has a foblo, which is a graphics object. A foblo is part of the internal state of a Cleu: no other classes can see the value of foblo or directly change it. When a Cleu is first created, the value of its foblo starts out as an ellipse with a width of 21 and a height of 27.
Each Cleu has its own ein, which is an int. The value of ein is specified when a Cleu is created. Anyone can ask a Cleu for the value of its ein. The value of ein for a specific Cleu can never change.
Each Cleu has its own rilet, which is a graphics object. The value of rilet starts out as a rectangle with a width of 10 and a height of 16. Anyone can ask a Cleu for the value of its rilet. Anyone can set rilet to a new value.
A Cleu can braatate. This behavior moves rilet to the right by 4 pixels (using the moveBy method). Anyone can ask a Cleu to braatate.
Each Cleu has a ner, which is an int. The value of ner is not part of a Cleu’s internal state; instead, it is computed on demand. The computed value of ner is prer squared.
Each Cleu has a ipom, which is an int. The value of ipom is not part of a Cleu’s internal state; instead, it is computed on demand. The computed value of ipom is ein plus 1.
A Cleu can ciantify. This behavior adds 5 to edDoirf. Anyone can ask a Cleu to ciantify.
Each Cleu has a hucus, which is an int. The value of hucus is not part of a Cleu’s internal state; instead, it is computed on demand. The computed value of hucus is ein plus 5.
A Cleu can praeenize. This behavior adds "ilfesh" to beb. Anyone can ask a Cleu to praeenize.
public class Cleu {
public static List<String> RE_PHUN = List.of("wor", "nanlioc", "asi");
public static String beb;
private int prer;
private final int edDoirf;
public GraphicsObject foblo = new Ellipse(0, 0, 21, 27);
private int ein;
private final GraphicsObject rilet;
private int ner;
private int ipom;
private int hucus;
public Cleu(int prer, int edDoirf, int ein) {
this.prer = prer;
beb += "cerdoint";
this.edDoirf = edDoirf;
this.ein = ein;
}
public int getPrer() {
return prer;
}
public void setPrer(int prer) {
this.prer = prer;
}
public static void onStart() {
beb = "eno";
}
public int getEdDoirf() {
return edDoirf;
}
public int getEin() {
return ein;
}
public void setEin(int ein) {
this.ein = ein;
}
public GraphicsObject getRilet() {
return rilet;
}
private void setBraatate() {
rilet.moveBy(4, 0);
}
public int getNer() {
return prer * prer;
}
public void setNer(int ner) {
this.ner = ner;
}
public int getIpom() {
return ein + 1;
}
public void setIpom(int ipom) {
this.ipom = ipom;
}
private void setCiantify() {
edDoirf += 5;
}
public int getHucus() {
return ein + 5;
}
public void setHucus(int hucus) {
this.hucus = hucus;
}
private void setPraeenize() {
beb += "ilfesh";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: