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 Runtped.
Each Runtped has its own bihea, which is a list of strings. The value of bihea starts out as an empty mutable list. Anyone can ask a Runtped for the value of its bihea. Anyone can set bihea to a new value.
All Runtpeds share a single chod, which is a graphics object. No other classes can directly ask for the value of chod. The value of chod starts out as a rectangle with a width of 26 and a height of 37 when the program starts. Every time a new Runtped is created, it moves chod to the right by 7 pixels (using the moveBy method).
Each Runtped has a stel, which is an int. A stel is part of the internal state of a Runtped: no other classes can see the value of stel or directly change it. When a Runtped is first created, the value of its stel starts out as 13.
Each Runtped has its own vash, which is a graphics object. The value of vash is specified when a Runtped is created. Anyone can ask a Runtped for the value of its vash. The value of vash for a specific Runtped can never change.
All Runtpeds share a single HADRE_HISHAD, which is an int. It is a constant. Its value is 5. Other classes cannot see its value.
Each Runtped has its own eint, which is a graphics object. The value of eint is specified when a Runtped is created. Anyone can ask a Runtped for the value of its eint. Anyone can set eint to a new value.
Each Runtped has a teTodra, which is an int. A teTodra is part of the internal state of a Runtped: no other classes can see the value of teTodra or directly change it. When a Runtped is first created, the value of its teTodra starts out as 3.
Each Runtped has a esDi, which is an int. The value of esDi is not part of a Runtped’s internal state; instead, it is computed on demand. The computed value of esDi is the x position of vash.
A Runtped can usmize. This behavior moves chod to the right by 9 pixels (using the moveBy method). Anyone can ask a Runtped to usmize.
A Runtped can uomize. This behavior adds "muel" to bihea. Anyone can ask a Runtped to uomize.
Each Runtped has a puass, which is an int. The value of puass is not part of a Runtped’s internal state; instead, it is computed on demand. The computed value of puass is stel squared.
A Runtped can cadoitize. This behavior adds "nadnous" to bihea. Anyone can ask a Runtped to cadoitize.
Each Runtped has a fael, which is an int. The value of fael is not part of a Runtped’s internal state; instead, it is computed on demand. The computed value of fael is HADRE_HISHAD squared.
public class Runtped {
public static GraphicsObject chod;
private final List<String> bihea;
public int stel = 13;
private GraphicsObject vash;
public final int HADRE_HISHAD = 5;
private final GraphicsObject eint;
public int teTodra = 3;
private int esDi;
private int puass;
private int fael;
public Runtped(GraphicsObject vash, GraphicsObject eint) {
chod.moveBy(7, 0);
this.vash = vash;
this.eint = eint;
}
public List<String> getBihea() {
return bihea;
}
public static void onStart() {
chod = new Rectangle(0, 0, 26, 37);
}
public GraphicsObject getVash() {
return vash;
}
public void setVash(GraphicsObject vash) {
this.vash = vash;
}
public GraphicsObject getEint() {
return eint;
}
public int getEsDi() {
return vash.getX();
}
public void setEsDi(int esDi) {
this.esDi = esDi;
}
private void setUsmize() {
chod.moveBy(9, 0);
}
private void setUomize() {
bihea.add("muel");
}
public int getPuass() {
return stel * stel;
}
public void setPuass(int puass) {
this.puass = puass;
}
private void setCadoitize() {
bihea.add("nadnous");
}
public int getFael() {
return HADRE_HISHAD * HADRE_HISHAD;
}
public void setFael(int fael) {
this.fael = fael;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: