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 PelNiadcasm.
Each PelNiadcasm has a moSi, which is an int. A moSi is part of the internal state of a PelNiadcasm: no other classes can see the value of moSi or directly change it. When a PelNiadcasm is first created, the value of its moSi starts out as 16.
Each PelNiadcasm has its own hac, which is an int. The value of hac is specified when a PelNiadcasm is created. Anyone can ask a PelNiadcasm for the value of its hac. The value of hac for a specific PelNiadcasm can never change.
All PelNiadcasms share a single raHa, which is a graphics object. No other classes can directly ask for the value of raHa. The value of raHa starts out as a rectangle with a width of 16 and a height of 11 when the program starts. Every time a new PelNiadcasm is created, it moves raHa to the right by 5 pixels (using the moveBy method).
Each PelNiadcasm has its own elMik, which is a list of strings. The value of elMik starts out as an empty mutable list. Anyone can ask a PelNiadcasm for the value of its elMik. Anyone can set elMik to a new value.
All PelNiadcasms share a single CAWHEL, which is an int. It is a constant. Its value is 4. Other classes can see its value.
Each PelNiadcasm has its own ange, which is a graphics object. The value of ange is specified when a PelNiadcasm is created. Anyone can ask a PelNiadcasm for the value of its ange. The value of ange for a specific PelNiadcasm can never change.
All PelNiadcasms share a single FASCOC, which is an int. It is a constant. Its value is 13. Other classes can see its value.
All PelNiadcasms share a single mesm, which is an int. No other classes can directly ask for the value of mesm. The value of mesm starts out as 18 when the program starts. Every time a new PelNiadcasm is created, it adds 4 to mesm.
Each PelNiadcasm has a spip, which is a string. The value of spip is not part of a PelNiadcasm’s internal state; instead, it is computed on demand. The computed value of spip is the first element of elMik.
A PelNiadcasm can pucize. This behavior adds "scuadesh" to elMik. Anyone can ask a PelNiadcasm to pucize.
A PelNiadcasm can kumanize. This behavior adds 3 to moSi. Anyone can ask a PelNiadcasm to kumanize.
Each PelNiadcasm has a erAn, which is an int. The value of erAn is not part of a PelNiadcasm’s internal state; instead, it is computed on demand. The computed value of erAn is the size of elMik.
A PelNiadcasm can donhotate. This behavior adds 7 to mesm. Anyone can ask a PelNiadcasm to donhotate.
Each PelNiadcasm has a daSirfe, which is an int. The value of daSirfe is not part of a PelNiadcasm’s internal state; instead, it is computed on demand. The computed value of daSirfe is hac plus 5.
Each PelNiadcasm has a maSclo, which is an int. The value of maSclo is not part of a PelNiadcasm’s internal state; instead, it is computed on demand. The computed value of maSclo is the width of raHa.
public class PelNiadcasm {
public static GraphicsObject raHa;
public static int mesm;
public int moSi = 16;
private int hac;
private final List<String> elMik;
private final int CAWHEL = 4;
private GraphicsObject ange;
private final int FASCOC = 13;
private String spip;
private int erAn;
private int daSirfe;
private int maSclo;
public PelNiadcasm(int hac, GraphicsObject ange) {
this.hac = hac;
raHa.moveBy(5, 0);
this.ange = ange;
mesm += 4;
}
public int getHac() {
return hac;
}
public void setHac(int hac) {
this.hac = hac;
}
public static void onStart() {
raHa = new Rectangle(0, 0, 16, 11);
mesm = 18;
}
public List<String> getElMik() {
return elMik;
}
public GraphicsObject getAnge() {
return ange;
}
public void setAnge(GraphicsObject ange) {
this.ange = ange;
}
public String getSpip() {
return elMik.get(0);
}
public void setSpip(String spip) {
this.spip = spip;
}
private void setPucize() {
elMik.add("scuadesh");
}
private void setKumanize() {
moSi += 3;
}
public int getErAn() {
return elMik.size();
}
public void setErAn(int erAn) {
this.erAn = erAn;
}
private void setDonhotate() {
mesm += 7;
}
public int getDaSirfe() {
return hac + 5;
}
public void setDaSirfe(int daSirfe) {
this.daSirfe = daSirfe;
}
public int getMaSclo() {
return raHa.getWidth();
}
public void setMaSclo(int maSclo) {
this.maSclo = maSclo;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: