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 Criaoist.
Each Criaoist has a boaw, which is an int. A boaw is part of the internal state of a Criaoist: no other classes can see the value of boaw or directly change it. When a Criaoist is first created, the value of its boaw starts out as 2.
All Criaoists share a single limi, which is a graphics object. No other classes can directly ask for the value of limi. The value of limi starts out as an ellipse with a width of 43 and a height of 44 when the program starts. Every time a new Criaoist is created, it moves limi to the right by 9 pixels (using the moveBy method).
Each Criaoist has a petra, which is an int. The value of petra is not part of a Criaoist’s internal state; instead, it is computed on demand. The computed value of petra is boaw plus 4.
public class Criaoist {
public static GraphicsObject limi;
public int boaw = 2;
private int petra;
public Criaoist() {
limi.moveBy(9, 0);
}
public static void onStart() {
limi = new Ellipse(0, 0, 43, 44);
}
public int getPetra() {
return boaw + 4;
}
public void setPetra(int petra) {
this.petra = petra;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: