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 Buhcen.
Each Buhcen has its own alni, which is a graphics object. The value of alni is specified when a Buhcen is created. Anyone can ask a Buhcen for the value of its alni. The value of alni for a specific Buhcen can never change.
All Buhcens share a single ATGISH, which is a list of strings. It is a constant. Its value is ["fadta", "soont"]. Other classes can see its value.
Each Buhcen has its own foDepir, which is a graphics object. The value of foDepir starts out as a rectangle with a width of 38 and a height of 11. Anyone can ask a Buhcen for the value of its foDepir. Anyone can set foDepir to a new value.
Each Buhcen has a owTris, which is an int. The value of owTris is not part of a Buhcen’s internal state; instead, it is computed on demand. The computed value of owTris is the size of ATGISH.
A Buhcen can tehetate. This behavior moves foDepir to the right by 2 pixels (using the moveBy method). Anyone can ask a Buhcen to tehetate.
public class Buhcen {
private static List<String> ATGISH = List.of("fadta", "soont");
private GraphicsObject alni;
private final GraphicsObject foDepir;
private int owTris;
public Buhcen(GraphicsObject alni) {
this.alni = alni;
}
public GraphicsObject getAlni() {
return alni;
}
public void setAlni(GraphicsObject alni) {
this.alni = alni;
}
public GraphicsObject getFoDepir() {
return foDepir;
}
public int getOwTris() {
return ATGISH.size();
}
public void setOwTris(int owTris) {
this.owTris = owTris;
}
private void setTehetate() {
foDepir.moveBy(2, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: