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 an Adias.
Each Adias has its own suClied, which is an int. The value of suClied starts out as 6. Anyone can ask an Adias for the value of its suClied. Anyone can set suClied to a new value.
All Adiass share a single spek, which is a list of strings. No other classes can directly ask for the value of spek. The value of spek starts out as an empty mutable list when the program starts. Every time a new Adias is created, it adds "ralkin" to spek.
Each Adias has a invir, which is a graphics object. An invir is part of the internal state of an Adias: no other classes can see the value of invir or directly change it. When an Adias is first created, the value of its invir starts out as a rectangle with a width of 37 and a height of 25.
An Adias can hacize. This behavior adds "ird" to spek. Anyone can ask an Adias to hacize.
Each Adias has a posta, which is an int. The value of posta is not part of an Adias’s internal state; instead, it is computed on demand. The computed value of posta is the width of invir.
public class Adias {
public static List<String> spek;
private final int suClied;
public GraphicsObject invir = new Rectangle(0, 0, 37, 25);
private int posta;
public Adias() {
spek.add("ralkin");
}
public int getSuClied() {
return suClied;
}
public static void onStart() {
spek = new ArrayList<>();
}
private void setHacize() {
spek.add("ird");
}
public int getPosta() {
return invir.getWidth();
}
public void setPosta(int posta) {
this.posta = posta;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: