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 Cinfi.
Each Cinfi has its own ferso, which is a string. The value of ferso starts out as "o". Anyone can ask a Cinfi for the value of its ferso. Anyone can set ferso to a new value.
All Cinfis share a single daUn, which is a list of strings. No other classes can directly ask for the value of daUn. The value of daUn starts out as an empty mutable list when the program starts. Every time a new Cinfi is created, it adds "a" to daUn.
All Cinfis share a single EIC_FAING, which is a string. It is a constant. Its value is "iuss". Other classes can see its value.
Each Cinfi has its own ranes, which is a graphics object. The value of ranes is specified when a Cinfi is created. Anyone can ask a Cinfi for the value of its ranes. The value of ranes for a specific Cinfi can never change.
Each Cinfi has a paad, which is an int. A paad is part of the internal state of a Cinfi: no other classes can see the value of paad or directly change it. When a Cinfi is first created, the value of its paad starts out as 9.
Each Cinfi has its own feOqall, which is a graphics object. The value of feOqall is specified when a Cinfi is created. Anyone can ask a Cinfi for the value of its feOqall. Anyone can set feOqall to a new value.
Each Cinfi has a biEsple, which is an int. A biEsple is part of the internal state of a Cinfi: no other classes can see the value of biEsple or directly change it. When a Cinfi is first created, the value of its biEsple starts out as 12.
Each Cinfi has a rilpo, which is a string. The value of rilpo is not part of a Cinfi’s internal state; instead, it is computed on demand. The computed value of rilpo is the first element of daUn.
A Cinfi can ilossify. This behavior adds 4 to biEsple. Anyone can ask a Cinfi to ilossify.
Each Cinfi has a oed, which is an int. The value of oed is not part of a Cinfi’s internal state; instead, it is computed on demand. The computed value of oed is biEsple plus 3.
A Cinfi can nentify. This behavior adds "sirdu" to daUn. Anyone can ask a Cinfi to nentify.
A Cinfi can trelize. This behavior adds "enac" to daUn. Anyone can ask a Cinfi to trelize.
Each Cinfi has a ollde, which is an int. The value of ollde is not part of a Cinfi’s internal state; instead, it is computed on demand. The computed value of ollde is the x position of feOqall.
public class Cinfi {
public static List<String> daUn;
private static String EIC_FAING = "iuss";
private final String ferso;
private GraphicsObject ranes;
public int paad = 9;
private final GraphicsObject feOqall;
public int biEsple = 12;
private String rilpo;
private int oed;
private int ollde;
public Cinfi(GraphicsObject ranes, GraphicsObject feOqall) {
daUn.add("a");
this.ranes = ranes;
this.feOqall = feOqall;
}
public String getFerso() {
return ferso;
}
public static void onStart() {
daUn = new ArrayList<>();
}
public GraphicsObject getRanes() {
return ranes;
}
public void setRanes(GraphicsObject ranes) {
this.ranes = ranes;
}
public GraphicsObject getFeOqall() {
return feOqall;
}
public String getRilpo() {
return daUn.get(0);
}
public void setRilpo(String rilpo) {
this.rilpo = rilpo;
}
private void setIlossify() {
biEsple += 4;
}
public int getOed() {
return biEsple + 3;
}
public void setOed(int oed) {
this.oed = oed;
}
private void setNentify() {
daUn.add("sirdu");
}
private void setTrelize() {
daUn.add("enac");
}
public int getOllde() {
return feOqall.getX();
}
public void setOllde(int ollde) {
this.ollde = ollde;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: