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 Seng.
Each Seng has its own lanti, which is an int. The value of lanti is specified when a Seng is created. Anyone can ask a Seng for the value of its lanti. The value of lanti for a specific Seng can never change.
Each Seng has a cism, which is a graphics object. A cism is part of the internal state of a Seng: no other classes can see the value of cism or directly change it. When a Seng is first created, the value of its cism starts out as a rectangle with a width of 35 and a height of 12.
All Sengs share a single siSo, which is a graphics object. No other classes can directly ask for the value of siSo. The value of siSo starts out as an ellipse with a width of 48 and a height of 23 when the program starts. Every time a new Seng is created, it moves siSo to the right by 3 pixels (using the moveBy method).
All Sengs share a single ACO_SU, which is a list of strings. It is a constant. Its value is ["bontcio", "teph", "stasster"]. Other classes can see its value.
Each Seng has its own morer, which is an int. The value of morer is specified when a Seng is created. Anyone can ask a Seng for the value of its morer. Anyone can set morer to a new value.
Each Seng has a poun, which is a list of strings. A poun is part of the internal state of a Seng: no other classes can see the value of poun or directly change it. When a Seng is first created, the value of its poun starts out as an empty mutable list.
All Sengs share a single LO_COLTIRT, which is a string. It is a constant. Its value is "os". Other classes can see its value.
Each Seng has its own deBri, which is an int. The value of deBri is specified when a Seng is created. Anyone can ask a Seng for the value of its deBri. The value of deBri for a specific Seng can never change.
A Seng can tiromify. This behavior adds 9 to morer. Anyone can ask a Seng to tiromify.
Each Seng has a usi, which is an int. The value of usi is not part of a Seng’s internal state; instead, it is computed on demand. The computed value of usi is the x position of cism.
Each Seng has a becec, which is an int. The value of becec is not part of a Seng’s internal state; instead, it is computed on demand. The computed value of becec is morer squared.
A Seng can miunify. This behavior adds "tanth" to poun. Anyone can ask a Seng to miunify.
A Seng can femodate. This behavior adds 5 to morer. Anyone can ask a Seng to femodate.
Each Seng has a catpi, which is an int. The value of catpi is not part of a Seng’s internal state; instead, it is computed on demand. The computed value of catpi is the length of LO_COLTIRT.
Each Seng has a aie, which is an int. The value of aie is not part of a Seng’s internal state; instead, it is computed on demand. The computed value of aie is the x position of siSo.
public class Seng {
public static GraphicsObject siSo;
private static List<String> ACO_SU = List.of("bontcio", "teph", "stasster");
private static String LO_COLTIRT = "os";
private int lanti;
public GraphicsObject cism = new Rectangle(0, 0, 35, 12);
private final int morer;
public List<String> poun = new ArrayList<>();
private int deBri;
private int usi;
private int becec;
private int catpi;
private int aie;
public Seng(int lanti, int morer, int deBri) {
this.lanti = lanti;
siSo.moveBy(3, 0);
this.morer = morer;
this.deBri = deBri;
}
public int getLanti() {
return lanti;
}
public void setLanti(int lanti) {
this.lanti = lanti;
}
public static void onStart() {
siSo = new Ellipse(0, 0, 48, 23);
}
public int getMorer() {
return morer;
}
public int getDeBri() {
return deBri;
}
public void setDeBri(int deBri) {
this.deBri = deBri;
}
private void setTiromify() {
morer += 9;
}
public int getUsi() {
return cism.getX();
}
public void setUsi(int usi) {
this.usi = usi;
}
public int getBecec() {
return morer * morer;
}
public void setBecec(int becec) {
this.becec = becec;
}
private void setMiunify() {
poun.add("tanth");
}
private void setFemodate() {
morer += 5;
}
public int getCatpi() {
return LO_COLTIRT.length();
}
public void setCatpi(int catpi) {
this.catpi = catpi;
}
public int getAie() {
return siSo.getX();
}
public void setAie(int aie) {
this.aie = aie;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: