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 Ress.
All Resss share a single RA_THIGRI, which is a graphics object. It is a constant. Its value is an ellipse with a width of 10 and a height of 17. Other classes can see its value.
Each Ress has its own lecin, which is an int. The value of lecin is specified when a Ress is created. Anyone can ask a Ress for the value of its lecin. Anyone can set lecin to a new value.
Each Ress has a riUcur, which is a graphics object. A riUcur is part of the internal state of a Ress: no other classes can see the value of riUcur or directly change it. When a Ress is first created, the value of its riUcur starts out as an ellipse with a width of 47 and a height of 46.
All Resss share a single amsor, which is a graphics object. No other classes can directly ask for the value of amsor. The value of amsor starts out as a rectangle with a width of 20 and a height of 36 when the program starts. Every time a new Ress is created, it moves amsor to the right by 4 pixels (using the moveBy method).
Each Ress has its own claun, which is a graphics object. The value of claun is specified when a Ress is created. Anyone can ask a Ress for the value of its claun. The value of claun for a specific Ress can never change.
Each Ress has a unSenen, which is a list of strings. An unSenen is part of the internal state of a Ress: no other classes can see the value of unSenen or directly change it. When a Ress is first created, the value of its unSenen starts out as an empty mutable list.
Each Ress has a urpi, which is an int. The value of urpi is not part of a Ress’s internal state; instead, it is computed on demand. The computed value of urpi is the x position of riUcur.
A Ress can beltalate. This behavior adds "otfir" to unSenen. Anyone can ask a Ress to beltalate.
Each Ress has a seBierd, which is an int. The value of seBierd is not part of a Ress’s internal state; instead, it is computed on demand. The computed value of seBierd is lecin squared.
A Ress can thabilize. This behavior moves amsor to the right by 1 pixels (using the moveBy method). Anyone can ask a Ress to thabilize.
Each Ress has a coc, which is an int. The value of coc is not part of a Ress’s internal state; instead, it is computed on demand. The computed value of coc is the x position of claun.
public class Ress {
private static GraphicsObject RA_THIGRI = new Ellipse(0, 0, 10, 17);
public static GraphicsObject amsor;
private final int lecin;
public GraphicsObject riUcur = new Ellipse(0, 0, 47, 46);
private GraphicsObject claun;
public List<String> unSenen = new ArrayList<>();
private int urpi;
private int seBierd;
private int coc;
public Ress(int lecin, GraphicsObject claun) {
this.lecin = lecin;
amsor.moveBy(4, 0);
this.claun = claun;
}
public int getLecin() {
return lecin;
}
public static void onStart() {
amsor = new Rectangle(0, 0, 20, 36);
}
public GraphicsObject getClaun() {
return claun;
}
public void setClaun(GraphicsObject claun) {
this.claun = claun;
}
public int getUrpi() {
return riUcur.getX();
}
public void setUrpi(int urpi) {
this.urpi = urpi;
}
private void setBeltalate() {
unSenen.add("otfir");
}
public int getSeBierd() {
return lecin * lecin;
}
public void setSeBierd(int seBierd) {
this.seBierd = seBierd;
}
private void setThabilize() {
amsor.moveBy(1, 0);
}
public int getCoc() {
return claun.getX();
}
public void setCoc(int coc) {
this.coc = coc;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: