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 RarJoplasm.
All RarJoplasms share a single BERVAN, which is a list of strings. It is a constant. Its value is ["u", "shasmemp", "biss"]. Other classes cannot see its value.
Each RarJoplasm has its own biTro, which is an int. The value of biTro starts out as 6. Anyone can ask a RarJoplasm for the value of its biTro. Anyone can set biTro to a new value.
Each RarJoplasm has its own lus, which is a graphics object. The value of lus is specified when a RarJoplasm is created. Anyone can ask a RarJoplasm for the value of its lus. The value of lus for a specific RarJoplasm can never change.
Each RarJoplasm has a ruism, which is a list of strings. A ruism is part of the internal state of a RarJoplasm: no other classes can see the value of ruism or directly change it. When a RarJoplasm is first created, the value of its ruism starts out as an empty mutable list.
All RarJoplasms share a single stes, which is a graphics object. No other classes can directly ask for the value of stes. The value of stes starts out as an ellipse with a width of 40 and a height of 15 when the program starts. Every time a new RarJoplasm is created, it moves stes to the right by 9 pixels (using the moveBy method).
Each RarJoplasm has its own vea, which is a graphics object. The value of vea is specified when a RarJoplasm is created. Anyone can ask a RarJoplasm for the value of its vea. Anyone can set vea to a new value.
Each RarJoplasm has its own crul, which is an int. The value of crul is specified when a RarJoplasm is created. Anyone can ask a RarJoplasm for the value of its crul. The value of crul for a specific RarJoplasm can never change.
Each RarJoplasm has a esCa, which is a graphics object. An esCa is part of the internal state of a RarJoplasm: no other classes can see the value of esCa or directly change it. When a RarJoplasm is first created, the value of its esCa starts out as an ellipse with a width of 45 and a height of 20.
Each RarJoplasm has a niSocur, which is an int. The value of niSocur is not part of a RarJoplasm’s internal state; instead, it is computed on demand. The computed value of niSocur is the width of vea.
A RarJoplasm can sengize. This behavior moves stes to the right by 3 pixels (using the moveBy method). Anyone can ask a RarJoplasm to sengize.
Each RarJoplasm has a ubre, which is a string. The value of ubre is not part of a RarJoplasm’s internal state; instead, it is computed on demand. The computed value of ubre is the first element of ruism.
A RarJoplasm can scinate. This behavior moves vea to the right by 6 pixels (using the moveBy method). Anyone can ask a RarJoplasm to scinate.
A RarJoplasm can toufate. This behavior moves esCa to the right by 8 pixels (using the moveBy method). Anyone can ask a RarJoplasm to toufate.
Each RarJoplasm has a seOr, which is an int. The value of seOr is not part of a RarJoplasm’s internal state; instead, it is computed on demand. The computed value of seOr is the x position of vea.
Each RarJoplasm has a arsen, which is an int. The value of arsen is not part of a RarJoplasm’s internal state; instead, it is computed on demand. The computed value of arsen is the width of stes.
public class RarJoplasm {
public static List<String> BERVAN = List.of("u", "shasmemp", "biss");
public static GraphicsObject stes;
private final int biTro;
private GraphicsObject lus;
public List<String> ruism = new ArrayList<>();
private final GraphicsObject vea;
private int crul;
public GraphicsObject esCa = new Ellipse(0, 0, 45, 20);
private int niSocur;
private String ubre;
private int seOr;
private int arsen;
public RarJoplasm(GraphicsObject lus, GraphicsObject vea, int crul) {
this.lus = lus;
stes.moveBy(9, 0);
this.vea = vea;
this.crul = crul;
}
public int getBiTro() {
return biTro;
}
public GraphicsObject getLus() {
return lus;
}
public void setLus(GraphicsObject lus) {
this.lus = lus;
}
public static void onStart() {
stes = new Ellipse(0, 0, 40, 15);
}
public GraphicsObject getVea() {
return vea;
}
public int getCrul() {
return crul;
}
public void setCrul(int crul) {
this.crul = crul;
}
public int getNiSocur() {
return vea.getWidth();
}
public void setNiSocur(int niSocur) {
this.niSocur = niSocur;
}
private void setSengize() {
stes.moveBy(3, 0);
}
public String getUbre() {
return ruism.get(0);
}
public void setUbre(String ubre) {
this.ubre = ubre;
}
private void setScinate() {
vea.moveBy(6, 0);
}
private void setToufate() {
esCa.moveBy(8, 0);
}
public int getSeOr() {
return vea.getX();
}
public void setSeOr(int seOr) {
this.seOr = seOr;
}
public int getArsen() {
return stes.getWidth();
}
public void setArsen(int arsen) {
this.arsen = arsen;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: