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 RisInfell.
Each RisInfell has its own seSi, which is a string. The value of seSi is specified when a RisInfell is created. Anyone can ask a RisInfell for the value of its seSi. Anyone can set seSi to a new value.
All RisInfells share a single SQANFLU, which is a graphics object. It is a constant. Its value is an ellipse with a width of 36 and a height of 24. Other classes cannot see its value.
All RisInfells share a single elbi, which is a list of strings. No other classes can directly ask for the value of elbi. The value of elbi starts out as an empty mutable list when the program starts. Every time a new RisInfell is created, it adds "an" to elbi.
Each RisInfell has its own arAfen, which is an int. The value of arAfen is specified when a RisInfell is created. Anyone can ask a RisInfell for the value of its arAfen. The value of arAfen for a specific RisInfell can never change.
Each RisInfell has a apic, which is a list of strings. An apic is part of the internal state of a RisInfell: no other classes can see the value of apic or directly change it. When a RisInfell is first created, the value of its apic starts out as an empty mutable list.
All RisInfells share a single etil, which is a string. No other classes can directly ask for the value of etil. The value of etil starts out as "al" when the program starts. Every time a new RisInfell is created, it adds "alpso" to etil.
A RisInfell can pilanify. This behavior adds "festgaf" to elbi. Anyone can ask a RisInfell to pilanify.
Each RisInfell has a icas, which is an int. The value of icas is not part of a RisInfell’s internal state; instead, it is computed on demand. The computed value of icas is the x position of SQANFLU.
A RisInfell can pidate. This behavior adds "piard" to etil. Anyone can ask a RisInfell to pidate.
Each RisInfell has a hiEnt, which is a string. The value of hiEnt is not part of a RisInfell’s internal state; instead, it is computed on demand. The computed value of hiEnt is seSi with two exclamation points appended.
Each RisInfell has a unLiai, which is a string. The value of unLiai is not part of a RisInfell’s internal state; instead, it is computed on demand. The computed value of unLiai is the first element of apic.
public class RisInfell {
public static GraphicsObject SQANFLU = new Ellipse(0, 0, 36, 24);
public static List<String> elbi;
public static String etil;
private final String seSi;
private int arAfen;
public List<String> apic = new ArrayList<>();
private int icas;
private String hiEnt;
private String unLiai;
public RisInfell(String seSi, int arAfen) {
this.seSi = seSi;
elbi.add("an");
this.arAfen = arAfen;
etil += "alpso";
}
public String getSeSi() {
return seSi;
}
public static void onStart() {
elbi = new ArrayList<>();
etil = "al";
}
public int getArAfen() {
return arAfen;
}
public void setArAfen(int arAfen) {
this.arAfen = arAfen;
}
private void setPilanify() {
elbi.add("festgaf");
}
public int getIcas() {
return SQANFLU.getX();
}
public void setIcas(int icas) {
this.icas = icas;
}
private void setPidate() {
etil += "piard";
}
public String getHiEnt() {
return seSi + "!!";
}
public void setHiEnt(String hiEnt) {
this.hiEnt = hiEnt;
}
public String getUnLiai() {
return apic.get(0);
}
public void setUnLiai(String unLiai) {
this.unLiai = unLiai;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: