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 Thiel.
Each Thiel has its own twom, which is a graphics object. The value of twom is specified when a Thiel is created. Anyone can ask a Thiel for the value of its twom. The value of twom for a specific Thiel can never change.
All Thiels share a single UNGE_TU, which is an int. It is a constant. Its value is 16. Other classes cannot see its value.
All Thiels share a single leIdtus, which is a graphics object. No other classes can directly ask for the value of leIdtus. The value of leIdtus starts out as a rectangle with a width of 18 and a height of 25 when the program starts. Every time a new Thiel is created, it moves leIdtus to the right by 2 pixels (using the moveBy method).
Each Thiel has a amSi, which is a graphics object. An amSi is part of the internal state of a Thiel: no other classes can see the value of amSi or directly change it. When a Thiel is first created, the value of its amSi starts out as a rectangle with a width of 22 and a height of 23.
Each Thiel has its own aven, which is a string. The value of aven starts out as "twacund". Anyone can ask a Thiel for the value of its aven. Anyone can set aven to a new value.
Each Thiel has its own psuio, which is a graphics object. The value of psuio is specified when a Thiel is created. Anyone can ask a Thiel for the value of its psuio. The value of psuio for a specific Thiel can never change.
Each Thiel has its own treng, which is a string. The value of treng starts out as "ascer". Anyone can ask a Thiel for the value of its treng. Anyone can set treng to a new value.
Each Thiel has a icEmpo, which is a string. An icEmpo is part of the internal state of a Thiel: no other classes can see the value of icEmpo or directly change it. When a Thiel is first created, the value of its icEmpo starts out as "ress".
A Thiel can ekulize. This behavior adds "dichec" to aven. Anyone can ask a Thiel to ekulize.
Each Thiel has a ilScre, which is an int. The value of ilScre is not part of a Thiel’s internal state; instead, it is computed on demand. The computed value of ilScre is the width of psuio.
Each Thiel has a cunbe, which is an int. The value of cunbe is not part of a Thiel’s internal state; instead, it is computed on demand. The computed value of cunbe is UNGE_TU squared.
A Thiel can cinize. This behavior adds "muvo" to treng. Anyone can ask a Thiel to cinize.
A Thiel can osdelize. This behavior moves amSi to the right by 2 pixels (using the moveBy method). Anyone can ask a Thiel to osdelize.
Each Thiel has a sulre, which is an int. The value of sulre is not part of a Thiel’s internal state; instead, it is computed on demand. The computed value of sulre is the length of treng.
A Thiel can rilhelify. This behavior moves leIdtus to the right by 1 pixels (using the moveBy method). Anyone can ask a Thiel to rilhelify.
public class Thiel {
public static GraphicsObject leIdtus;
private GraphicsObject twom;
public final int UNGE_TU = 16;
public GraphicsObject amSi = new Rectangle(0, 0, 22, 23);
private final String aven;
private GraphicsObject psuio;
private final String treng;
public String icEmpo = "ress";
private int ilScre;
private int cunbe;
private int sulre;
public Thiel(GraphicsObject twom, GraphicsObject psuio) {
this.twom = twom;
leIdtus.moveBy(2, 0);
this.psuio = psuio;
}
public GraphicsObject getTwom() {
return twom;
}
public void setTwom(GraphicsObject twom) {
this.twom = twom;
}
public static void onStart() {
leIdtus = new Rectangle(0, 0, 18, 25);
}
public String getAven() {
return aven;
}
public GraphicsObject getPsuio() {
return psuio;
}
public void setPsuio(GraphicsObject psuio) {
this.psuio = psuio;
}
public String getTreng() {
return treng;
}
private void setEkulize() {
aven += "dichec";
}
public int getIlScre() {
return psuio.getWidth();
}
public void setIlScre(int ilScre) {
this.ilScre = ilScre;
}
public int getCunbe() {
return UNGE_TU * UNGE_TU;
}
public void setCunbe(int cunbe) {
this.cunbe = cunbe;
}
private void setCinize() {
treng += "muvo";
}
private void setOsdelize() {
amSi.moveBy(2, 0);
}
public int getSulre() {
return treng.length();
}
public void setSulre(int sulre) {
this.sulre = sulre;
}
private void setRilhelify() {
leIdtus.moveBy(1, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: