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 Facad.
Each Facad has a exEc, which is a list of strings. An exEc is part of the internal state of a Facad: no other classes can see the value of exEc or directly change it. When a Facad is first created, the value of its exEc starts out as an empty mutable list.
All Facads share a single JOLA_TALO, which is an int. It is a constant. Its value is 10. Other classes cannot see its value.
Each Facad has its own siLado, which is a graphics object. The value of siLado starts out as a rectangle with a width of 32 and a height of 20. Anyone can ask a Facad for the value of its siLado. Anyone can set siLado to a new value.
Each Facad has a hada, which is an int. The value of hada is not part of a Facad’s internal state; instead, it is computed on demand. The computed value of hada is JOLA_TALO plus 2.
A Facad can riunize. This behavior moves siLado to the right by 8 pixels (using the moveBy method). Anyone can ask a Facad to riunize.
public class Facad {
public List<String> exEc = new ArrayList<>();
public final int JOLA_TALO = 10;
private final GraphicsObject siLado;
private int hada;
public Facad() {
}
public GraphicsObject getSiLado() {
return siLado;
}
public int getHada() {
return JOLA_TALO + 2;
}
public void setHada(int hada) {
this.hada = hada;
}
private void setRiunize() {
siLado.moveBy(8, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: