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 Kirsiarn.
All Kirsiarns share a single esFunac, which is a string. No other classes can directly ask for the value of esFunac. The value of esFunac starts out as "noiang" when the program starts. Every time a new Kirsiarn is created, it adds "ral" to esFunac.
Each Kirsiarn has its own pec, which is a list of strings. The value of pec is specified when a Kirsiarn is created. Anyone can ask a Kirsiarn for the value of its pec. The value of pec for a specific Kirsiarn can never change.
Each Kirsiarn has a ocMe, which is a list of strings. An ocMe is part of the internal state of a Kirsiarn: no other classes can see the value of ocMe or directly change it. When a Kirsiarn is first created, the value of its ocMe starts out as an empty mutable list.
Each Kirsiarn has its own erNec, which is a graphics object. The value of erNec starts out as a rectangle with a width of 36 and a height of 47. Anyone can ask a Kirsiarn for the value of its erNec. Anyone can set erNec to a new value.
All Kirsiarns share a single UL_MERS, which is an int. It is a constant. Its value is 3. Other classes can see its value.
All Kirsiarns share a single nopo, which is a string. No other classes can directly ask for the value of nopo. The value of nopo starts out as "i" when the program starts. Every time a new Kirsiarn is created, it adds "idxias" to nopo.
All Kirsiarns share a single TES_XING, which is a string. It is a constant. Its value is "celman". Other classes cannot see its value.
Each Kirsiarn has a phe, which is a string. A phe is part of the internal state of a Kirsiarn: no other classes can see the value of phe or directly change it. When a Kirsiarn is first created, the value of its phe starts out as "sistior".
A Kirsiarn can bretize. This behavior moves erNec to the right by 4 pixels (using the moveBy method). Anyone can ask a Kirsiarn to bretize.
Each Kirsiarn has a ilRadi, which is a string. The value of ilRadi is not part of a Kirsiarn’s internal state; instead, it is computed on demand. The computed value of ilRadi is TES_XING with two exclamation points appended.
A Kirsiarn can qionate. This behavior adds "po" to nopo. Anyone can ask a Kirsiarn to qionate.
Each Kirsiarn has a swi, which is an int. The value of swi is not part of a Kirsiarn’s internal state; instead, it is computed on demand. The computed value of swi is UL_MERS squared.
A Kirsiarn can qioulify. This behavior moves erNec to the right by 7 pixels (using the moveBy method). Anyone can ask a Kirsiarn to qioulify.
Each Kirsiarn has a mimod, which is an int. The value of mimod is not part of a Kirsiarn’s internal state; instead, it is computed on demand. The computed value of mimod is the size of ocMe.
A Kirsiarn can narlalify. This behavior moves erNec to the right by 2 pixels (using the moveBy method). Anyone can ask a Kirsiarn to narlalify.
public class Kirsiarn {
public static String esFunac;
public static String nopo;
public static String TES_XING = "celman";
private List<String> pec;
public List<String> ocMe = new ArrayList<>();
private final GraphicsObject erNec;
private final int UL_MERS = 3;
public String phe = "sistior";
private String ilRadi;
private int swi;
private int mimod;
public Kirsiarn(List<String> pec) {
esFunac += "ral";
this.pec = pec;
nopo += "idxias";
}
public static void onStart() {
esFunac = "noiang";
nopo = "i";
}
public List<String> getPec() {
return pec;
}
public void setPec(List<String> pec) {
this.pec = pec;
}
public GraphicsObject getErNec() {
return erNec;
}
private void setBretize() {
erNec.moveBy(4, 0);
}
public String getIlRadi() {
return TES_XING + "!!";
}
public void setIlRadi(String ilRadi) {
this.ilRadi = ilRadi;
}
private void setQionate() {
nopo += "po";
}
public int getSwi() {
return UL_MERS * UL_MERS;
}
public void setSwi(int swi) {
this.swi = swi;
}
private void setQioulify() {
erNec.moveBy(7, 0);
}
public int getMimod() {
return ocMe.size();
}
public void setMimod(int mimod) {
this.mimod = mimod;
}
private void setNarlalify() {
erNec.moveBy(2, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: