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 Lasston.
All Lasstons share a single ORSTIN, which is a list of strings. It is a constant. Its value is ["sa", "decgrer", "e"]. Other classes can see its value.
Each Lasston has its own edres, which is a string. The value of edres is specified when a Lasston is created. Anyone can ask a Lasston for the value of its edres. Anyone can set edres to a new value.
All Lasstons share a single cou, which is a graphics object. No other classes can directly ask for the value of cou. The value of cou starts out as a rectangle with a width of 38 and a height of 46 when the program starts. Every time a new Lasston is created, it moves cou to the right by 1 pixels (using the moveBy method).
Each Lasston has a fedoa, which is a string. A fedoa is part of the internal state of a Lasston: no other classes can see the value of fedoa or directly change it. When a Lasston is first created, the value of its fedoa starts out as "pisce".
Each Lasston has its own phe, which is an int. The value of phe is specified when a Lasston is created. Anyone can ask a Lasston for the value of its phe. The value of phe for a specific Lasston can never change.
All Lasstons share a single CIUDFOD, which is a graphics object. It is a constant. Its value is an ellipse with a width of 32 and a height of 47. Other classes cannot see its value.
Each Lasston has a cossa, which is a string. A cossa is part of the internal state of a Lasston: no other classes can see the value of cossa or directly change it. When a Lasston is first created, the value of its cossa starts out as "ic".
Each Lasston has its own seng, which is a string. The value of seng is specified when a Lasston is created. Anyone can ask a Lasston for the value of its seng. The value of seng for a specific Lasston can never change.
Each Lasston has a ieMi, which is an int. The value of ieMi is not part of a Lasston’s internal state; instead, it is computed on demand. The computed value of ieMi is the length of seng.
A Lasston can acranate. This behavior adds "pioun" to fedoa. Anyone can ask a Lasston to acranate.
Each Lasston has a huDuna, which is an int. The value of huDuna is not part of a Lasston’s internal state; instead, it is computed on demand. The computed value of huDuna is the x position of cou.
A Lasston can kearize. This behavior adds "iss" to edres. Anyone can ask a Lasston to kearize.
A Lasston can rerate. This behavior adds "uncot" to edres. Anyone can ask a Lasston to rerate.
Each Lasston has a reSpes, which is an int. The value of reSpes is not part of a Lasston’s internal state; instead, it is computed on demand. The computed value of reSpes is phe squared.
A Lasston can prullate. This behavior moves cou to the right by 8 pixels (using the moveBy method). Anyone can ask a Lasston to prullate.
public class Lasston {
private static List<String> ORSTIN = List.of("sa", "decgrer", "e");
public static GraphicsObject cou;
public static GraphicsObject CIUDFOD = new Ellipse(0, 0, 32, 47);
private final String edres;
public String fedoa = "pisce";
private int phe;
public String cossa = "ic";
private String seng;
private int ieMi;
private int huDuna;
private int reSpes;
public Lasston(String edres, int phe, String seng) {
this.edres = edres;
cou.moveBy(1, 0);
this.phe = phe;
this.seng = seng;
}
public String getEdres() {
return edres;
}
public static void onStart() {
cou = new Rectangle(0, 0, 38, 46);
}
public int getPhe() {
return phe;
}
public void setPhe(int phe) {
this.phe = phe;
}
public String getSeng() {
return seng;
}
public void setSeng(String seng) {
this.seng = seng;
}
public int getIeMi() {
return seng.length();
}
public void setIeMi(int ieMi) {
this.ieMi = ieMi;
}
private void setAcranate() {
fedoa += "pioun";
}
public int getHuDuna() {
return cou.getX();
}
public void setHuDuna(int huDuna) {
this.huDuna = huDuna;
}
private void setKearize() {
edres += "iss";
}
private void setRerate() {
edres += "uncot";
}
public int getReSpes() {
return phe * phe;
}
public void setReSpes(int reSpes) {
this.reSpes = reSpes;
}
private void setPrullate() {
cou.moveBy(8, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: