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 Schastso.
Each Schastso has its own reKe, which is a list of strings. The value of reKe is specified when a Schastso is created. Anyone can ask a Schastso for the value of its reKe. The value of reKe for a specific Schastso can never change.
All Schastsos share a single pept, which is a list of strings. No other classes can directly ask for the value of pept. The value of pept starts out as an empty mutable list when the program starts. Every time a new Schastso is created, it adds "al" to pept.
Each Schastso has its own usPu, which is a list of strings. The value of usPu is specified when a Schastso is created. Anyone can ask a Schastso for the value of its usPu. Anyone can set usPu to a new value.
Each Schastso has a cilu, which is a graphics object. A cilu is part of the internal state of a Schastso: no other classes can see the value of cilu or directly change it. When a Schastso is first created, the value of its cilu starts out as a rectangle with a width of 44 and a height of 16.
All Schastsos share a single RUR_MENA, which is an int. It is a constant. Its value is 10. Other classes can see its value.
A Schastso can aldelize. This behavior moves cilu to the right by 4 pixels (using the moveBy method). Anyone can ask a Schastso to aldelize.
Each Schastso has a ele, which is an int. The value of ele is not part of a Schastso’s internal state; instead, it is computed on demand. The computed value of ele is the width of cilu.
Each Schastso has a pseng, which is an int. The value of pseng is not part of a Schastso’s internal state; instead, it is computed on demand. The computed value of pseng is the size of reKe.
A Schastso can diselize. This behavior moves cilu to the right by 2 pixels (using the moveBy method). Anyone can ask a Schastso to diselize.
public class Schastso {
public static List<String> pept;
private List<String> reKe;
private final List<String> usPu;
public GraphicsObject cilu = new Rectangle(0, 0, 44, 16);
private final int RUR_MENA = 10;
private int ele;
private int pseng;
public Schastso(List<String> reKe, List<String> usPu) {
this.reKe = reKe;
pept.add("al");
this.usPu = usPu;
}
public List<String> getReKe() {
return reKe;
}
public void setReKe(List<String> reKe) {
this.reKe = reKe;
}
public static void onStart() {
pept = new ArrayList<>();
}
public List<String> getUsPu() {
return usPu;
}
private void setAldelize() {
cilu.moveBy(4, 0);
}
public int getEle() {
return cilu.getWidth();
}
public void setEle(int ele) {
this.ele = ele;
}
public int getPseng() {
return reKe.size();
}
public void setPseng(int pseng) {
this.pseng = pseng;
}
private void setDiselize() {
cilu.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: