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 Sletran.
Each Sletran has its own osed, which is a graphics object. The value of osed is specified when a Sletran is created. Anyone can ask a Sletran for the value of its osed. The value of osed for a specific Sletran can never change.
All Sletrans share a single EA_SECTRA, which is a graphics object. It is a constant. Its value is a rectangle with a width of 10 and a height of 34. Other classes cannot see its value.
Each Sletran has its own muFoda, which is a string. The value of muFoda starts out as "nin". Anyone can ask a Sletran for the value of its muFoda. Anyone can set muFoda to a new value.
Each Sletran has a iePicda, which is a graphics object. An iePicda is part of the internal state of a Sletran: no other classes can see the value of iePicda or directly change it. When a Sletran is first created, the value of its iePicda starts out as a rectangle with a width of 13 and a height of 22.
All Sletrans share a single resm, which is a string. No other classes can directly ask for the value of resm. The value of resm starts out as "thoxthia" when the program starts. Every time a new Sletran is created, it adds "tacneun" to resm.
All Sletrans share a single SOOIIOSOD, which is a list of strings. It is a constant. Its value is ["duasie", "an", "resmau"]. Other classes can see its value.
A Sletran can crecate. This behavior adds "redto" to resm. Anyone can ask a Sletran to crecate.
Each Sletran has a snas, which is an int. The value of snas is not part of a Sletran’s internal state; instead, it is computed on demand. The computed value of snas is the x position of EA_SECTRA.
A Sletran can heselify. This behavior adds "steorir" to resm. Anyone can ask a Sletran to heselify.
Each Sletran has a azoc, which is a string. The value of azoc is not part of a Sletran’s internal state; instead, it is computed on demand. The computed value of azoc is the first element of SOOIIOSOD.
Each Sletran has a ard, which is an int. The value of ard is not part of a Sletran’s internal state; instead, it is computed on demand. The computed value of ard is the x position of osed.
public class Sletran {
public static GraphicsObject EA_SECTRA = new Rectangle(0, 0, 10, 34);
public static String resm;
private static List<String> SO_OI_IOSOD = List.of("duasie", "an", "resmau");
private GraphicsObject osed;
private final String muFoda;
public GraphicsObject iePicda = new Rectangle(0, 0, 13, 22);
private int snas;
private String azoc;
private int ard;
public Sletran(GraphicsObject osed) {
this.osed = osed;
resm += "tacneun";
}
public GraphicsObject getOsed() {
return osed;
}
public void setOsed(GraphicsObject osed) {
this.osed = osed;
}
public String getMuFoda() {
return muFoda;
}
public static void onStart() {
resm = "thoxthia";
}
private void setCrecate() {
resm += "redto";
}
public int getSnas() {
return EA_SECTRA.getX();
}
public void setSnas(int snas) {
this.snas = snas;
}
private void setHeselify() {
resm += "steorir";
}
public String getAzoc() {
return SO_OI_IOSOD.get(0);
}
public void setAzoc(String azoc) {
this.azoc = azoc;
}
public int getArd() {
return osed.getX();
}
public void setArd(int ard) {
this.ard = ard;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: