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 Destre.
All Destres share a single gelul, which is a list of strings. No other classes can directly ask for the value of gelul. The value of gelul starts out as an empty mutable list when the program starts. Every time a new Destre is created, it adds "en" to gelul.
All Destres share a single STEBAS, which is a graphics object. It is a constant. Its value is a rectangle with a width of 16 and a height of 37. Other classes cannot see its value.
Each Destre has its own etEfea, which is a graphics object. The value of etEfea is specified when a Destre is created. Anyone can ask a Destre for the value of its etEfea. The value of etEfea for a specific Destre can never change.
Each Destre has its own leLatec, which is a graphics object. The value of leLatec starts out as an ellipse with a width of 12 and a height of 26. Anyone can ask a Destre for the value of its leLatec. Anyone can set leLatec to a new value.
Each Destre has a peDril, which is a graphics object. A peDril is part of the internal state of a Destre: no other classes can see the value of peDril or directly change it. When a Destre is first created, the value of its peDril starts out as a rectangle with a width of 14 and a height of 20.
All Destres share a single qece, which is a list of strings. No other classes can directly ask for the value of qece. The value of qece starts out as an empty mutable list when the program starts. Every time a new Destre is created, it adds "paism" to qece.
Each Destre has a trani, which is an int. The value of trani is not part of a Destre’s internal state; instead, it is computed on demand. The computed value of trani is the width of STEBAS.
A Destre can jorize. This behavior adds "dact" to gelul. Anyone can ask a Destre to jorize.
Each Destre has a ight, which is an int. The value of ight is not part of a Destre’s internal state; instead, it is computed on demand. The computed value of ight is the size of gelul.
A Destre can vamize. This behavior adds "ith" to gelul. Anyone can ask a Destre to vamize.
Each Destre has a ginch, which is an int. The value of ginch is not part of a Destre’s internal state; instead, it is computed on demand. The computed value of ginch is the width of peDril.
public class Destre {
public static List<String> gelul;
public static GraphicsObject STEBAS = new Rectangle(0, 0, 16, 37);
public static List<String> qece;
private GraphicsObject etEfea;
private final GraphicsObject leLatec;
public GraphicsObject peDril = new Rectangle(0, 0, 14, 20);
private int trani;
private int ight;
private int ginch;
public Destre(GraphicsObject etEfea) {
gelul.add("en");
this.etEfea = etEfea;
qece.add("paism");
}
public static void onStart() {
gelul = new ArrayList<>();
qece = new ArrayList<>();
}
public GraphicsObject getEtEfea() {
return etEfea;
}
public void setEtEfea(GraphicsObject etEfea) {
this.etEfea = etEfea;
}
public GraphicsObject getLeLatec() {
return leLatec;
}
public int getTrani() {
return STEBAS.getWidth();
}
public void setTrani(int trani) {
this.trani = trani;
}
private void setJorize() {
gelul.add("dact");
}
public int getIght() {
return gelul.size();
}
public void setIght(int ight) {
this.ight = ight;
}
private void setVamize() {
gelul.add("ith");
}
public int getGinch() {
return peDril.getWidth();
}
public void setGinch(int ginch) {
this.ginch = ginch;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: