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 Speorfo.
Each Speorfo has a deu, which is a list of strings. A deu is part of the internal state of a Speorfo: no other classes can see the value of deu or directly change it. When a Speorfo is first created, the value of its deu starts out as an empty mutable list.
Each Speorfo has its own armas, which is a string. The value of armas is specified when a Speorfo is created. Anyone can ask a Speorfo for the value of its armas. The value of armas for a specific Speorfo can never change.
Each Speorfo has its own gri, which is a graphics object. The value of gri starts out as a rectangle with a width of 37 and a height of 43. Anyone can ask a Speorfo for the value of its gri. Anyone can set gri to a new value.
All Speorfos share a single pras, which is a graphics object. No other classes can directly ask for the value of pras. The value of pras starts out as a rectangle with a width of 38 and a height of 46 when the program starts. Every time a new Speorfo is created, it moves pras to the right by 4 pixels (using the moveBy method).
All Speorfos share a single THOC_STECDOR, which is a graphics object. It is a constant. Its value is a rectangle with a width of 25 and a height of 20. Other classes cannot see its value.
Each Speorfo has a eoIss, which is an int. The value of eoIss is not part of a Speorfo’s internal state; instead, it is computed on demand. The computed value of eoIss is the x position of gri.
A Speorfo can priasize. This behavior adds "rer" to deu. Anyone can ask a Speorfo to priasize.
A Speorfo can nafgelify. This behavior moves gri to the right by 1 pixels (using the moveBy method). Anyone can ask a Speorfo to nafgelify.
Each Speorfo has a osRont, which is an int. The value of osRont is not part of a Speorfo’s internal state; instead, it is computed on demand. The computed value of osRont is the width of THOC_STECDOR.
public class Speorfo {
public static GraphicsObject pras;
public static GraphicsObject THOC_STECDOR = new Rectangle(0, 0, 25, 20);
public List<String> deu = new ArrayList<>();
private String armas;
private final GraphicsObject gri;
private int eoIss;
private int osRont;
public Speorfo(String armas) {
this.armas = armas;
pras.moveBy(4, 0);
}
public String getArmas() {
return armas;
}
public void setArmas(String armas) {
this.armas = armas;
}
public GraphicsObject getGri() {
return gri;
}
public static void onStart() {
pras = new Rectangle(0, 0, 38, 46);
}
public int getEoIss() {
return gri.getX();
}
public void setEoIss(int eoIss) {
this.eoIss = eoIss;
}
private void setPriasize() {
deu.add("rer");
}
private void setNafgelify() {
gri.moveBy(1, 0);
}
public int getOsRont() {
return THOC_STECDOR.getWidth();
}
public void setOsRont(int osRont) {
this.osRont = osRont;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: