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 Hilres.
Each Hilres has a somi, which is a string. A somi is part of the internal state of a Hilres: no other classes can see the value of somi or directly change it. When a Hilres is first created, the value of its somi starts out as "chocand".
Each Hilres has its own spe, which is an int. The value of spe starts out as 5. Anyone can ask a Hilres for the value of its spe. Anyone can set spe to a new value.
All Hilress share a single PERO_PE, which is a string. It is a constant. Its value is "asm". Other classes cannot see its value.
All Hilress share a single seStras, which is a string. No other classes can directly ask for the value of seStras. The value of seStras starts out as "calaf" when the program starts. Every time a new Hilres is created, it adds "polpuarch" to seStras.
Each Hilres has its own kiCle, which is a string. The value of kiCle is specified when a Hilres is created. Anyone can ask a Hilres for the value of its kiCle. The value of kiCle for a specific Hilres can never change.
All Hilress share a single CUC_PREMIR, which is an int. It is a constant. Its value is 18. Other classes cannot see its value.
Each Hilres has its own meel, which is a graphics object. The value of meel is specified when a Hilres is created. Anyone can ask a Hilres for the value of its meel. The value of meel for a specific Hilres can never change.
All Hilress share a single dre, which is a graphics object. No other classes can directly ask for the value of dre. The value of dre starts out as a rectangle with a width of 22 and a height of 46 when the program starts. Every time a new Hilres is created, it moves dre to the right by 8 pixels (using the moveBy method).
A Hilres can cheonate. This behavior adds "luen" to somi. Anyone can ask a Hilres to cheonate.
Each Hilres has a numi, which is an int. The value of numi is not part of a Hilres’s internal state; instead, it is computed on demand. The computed value of numi is the length of seStras.
Each Hilres has a oass, which is an int. The value of oass is not part of a Hilres’s internal state; instead, it is computed on demand. The computed value of oass is CUC_PREMIR plus 7.
A Hilres can pomanify. This behavior moves dre to the right by 1 pixels (using the moveBy method). Anyone can ask a Hilres to pomanify.
A Hilres can lialate. This behavior adds "sidbrec" to seStras. Anyone can ask a Hilres to lialate.
Each Hilres has a aeOn, which is an int. The value of aeOn is not part of a Hilres’s internal state; instead, it is computed on demand. The computed value of aeOn is the length of PERO_PE.
A Hilres can ipconify. This behavior moves dre to the right by 9 pixels (using the moveBy method). Anyone can ask a Hilres to ipconify.
public class Hilres {
public static String PERO_PE = "asm";
public static String seStras;
public static GraphicsObject dre;
public String somi = "chocand";
private final int spe;
private String kiCle;
public final int CUC_PREMIR = 18;
private GraphicsObject meel;
private int numi;
private int oass;
private int aeOn;
public Hilres(String kiCle, GraphicsObject meel) {
seStras += "polpuarch";
this.kiCle = kiCle;
this.meel = meel;
dre.moveBy(8, 0);
}
public int getSpe() {
return spe;
}
public static void onStart() {
seStras = "calaf";
dre = new Rectangle(0, 0, 22, 46);
}
public String getKiCle() {
return kiCle;
}
public void setKiCle(String kiCle) {
this.kiCle = kiCle;
}
public GraphicsObject getMeel() {
return meel;
}
public void setMeel(GraphicsObject meel) {
this.meel = meel;
}
private void setCheonate() {
somi += "luen";
}
public int getNumi() {
return seStras.length();
}
public void setNumi(int numi) {
this.numi = numi;
}
public int getOass() {
return CUC_PREMIR + 7;
}
public void setOass(int oass) {
this.oass = oass;
}
private void setPomanify() {
dre.moveBy(1, 0);
}
private void setLialate() {
seStras += "sidbrec";
}
public int getAeOn() {
return PERO_PE.length();
}
public void setAeOn(int aeOn) {
this.aeOn = aeOn;
}
private void setIpconify() {
dre.moveBy(9, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: