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 Tharxo.
All Tharxos share a single wres, which is an int. No other classes can directly ask for the value of wres. The value of wres starts out as 2 when the program starts. Every time a new Tharxo is created, it adds 6 to wres.
Each Tharxo has its own scras, which is an int. The value of scras starts out as 11. Anyone can ask a Tharxo for the value of its scras. Anyone can set scras to a new value.
Each Tharxo has its own ceFes, which is an int. The value of ceFes is specified when a Tharxo is created. Anyone can ask a Tharxo for the value of its ceFes. The value of ceFes for a specific Tharxo can never change.
Each Tharxo has a vos, which is a string. A vos is part of the internal state of a Tharxo: no other classes can see the value of vos or directly change it. When a Tharxo is first created, the value of its vos starts out as "doinlel".
All Tharxos share a single BI_ONAR, which is an int. It is a constant. Its value is 19. Other classes can see its value.
All Tharxos share a single ilBla, which is a graphics object. No other classes can directly ask for the value of ilBla. The value of ilBla starts out as an ellipse with a width of 44 and a height of 30 when the program starts. Every time a new Tharxo is created, it moves ilBla to the right by 6 pixels (using the moveBy method).
Each Tharxo has its own heMo, which is a string. The value of heMo is specified when a Tharxo is created. Anyone can ask a Tharxo for the value of its heMo. Anyone can set heMo to a new value.
All Tharxos share a single CHELNOLL, which is a graphics object. It is a constant. Its value is an ellipse with a width of 43 and a height of 43. Other classes cannot see its value.
A Tharxo can hephify. This behavior adds "osprosm" to vos. Anyone can ask a Tharxo to hephify.
Each Tharxo has a peras, which is an int. The value of peras is not part of a Tharxo’s internal state; instead, it is computed on demand. The computed value of peras is the length of heMo.
Each Tharxo has a idSnec, which is an int. The value of idSnec is not part of a Tharxo’s internal state; instead, it is computed on demand. The computed value of idSnec is scras squared.
A Tharxo can heantify. This behavior moves ilBla to the right by 3 pixels (using the moveBy method). Anyone can ask a Tharxo to heantify.
A Tharxo can asdecify. This behavior adds 3 to scras. Anyone can ask a Tharxo to asdecify.
Each Tharxo has a modar, which is an int. The value of modar is not part of a Tharxo’s internal state; instead, it is computed on demand. The computed value of modar is ceFes squared.
A Tharxo can antfotate. This behavior adds "strontso" to heMo. Anyone can ask a Tharxo to antfotate.
public class Tharxo {
public static int wres;
public static GraphicsObject ilBla;
public static GraphicsObject CHELNOLL = new Ellipse(0, 0, 43, 43);
private final int scras;
private int ceFes;
public String vos = "doinlel";
private final int BI_ONAR = 19;
private final String heMo;
private int peras;
private int idSnec;
private int modar;
public Tharxo(int ceFes, String heMo) {
wres += 6;
this.ceFes = ceFes;
ilBla.moveBy(6, 0);
this.heMo = heMo;
}
public static void onStart() {
wres = 2;
ilBla = new Ellipse(0, 0, 44, 30);
}
public int getScras() {
return scras;
}
public int getCeFes() {
return ceFes;
}
public void setCeFes(int ceFes) {
this.ceFes = ceFes;
}
public String getHeMo() {
return heMo;
}
private void setHephify() {
vos += "osprosm";
}
public int getPeras() {
return heMo.length();
}
public void setPeras(int peras) {
this.peras = peras;
}
public int getIdSnec() {
return scras * scras;
}
public void setIdSnec(int idSnec) {
this.idSnec = idSnec;
}
private void setHeantify() {
ilBla.moveBy(3, 0);
}
private void setAsdecify() {
scras += 3;
}
public int getModar() {
return ceFes * ceFes;
}
public void setModar(int modar) {
this.modar = modar;
}
private void setAntfotate() {
heMo += "strontso";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: