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 Giar.
Each Giar has a virti, which is a string. A virti is part of the internal state of a Giar: no other classes can see the value of virti or directly change it. When a Giar is first created, the value of its virti starts out as "repu".
All Giars share a single nioll, which is a graphics object. No other classes can directly ask for the value of nioll. The value of nioll starts out as a rectangle with a width of 33 and a height of 11 when the program starts. Every time a new Giar is created, it moves nioll to the right by 4 pixels (using the moveBy method).
All Giars share a single KORSTRAL, which is an int. It is a constant. Its value is 12. Other classes can see its value.
Each Giar has its own ician, which is a graphics object. The value of ician starts out as a rectangle with a width of 18 and a height of 18. Anyone can ask a Giar for the value of its ician. Anyone can set ician to a new value.
Each Giar has a biDe, which is an int. The value of biDe is not part of a Giar’s internal state; instead, it is computed on demand. The computed value of biDe is KORSTRAL squared.
A Giar can tasmate. This behavior moves nioll to the right by 4 pixels (using the moveBy method). Anyone can ask a Giar to tasmate.
Each Giar has a diade, which is an int. The value of diade is not part of a Giar’s internal state; instead, it is computed on demand. The computed value of diade is KORSTRAL squared.
public class Giar {
public static GraphicsObject nioll;
public String virti = "repu";
private final int KORSTRAL = 12;
private final GraphicsObject ician;
private int biDe;
private int diade;
public Giar() {
nioll.moveBy(4, 0);
}
public static void onStart() {
nioll = new Rectangle(0, 0, 33, 11);
}
public GraphicsObject getIcian() {
return ician;
}
public int getBiDe() {
return KORSTRAL * KORSTRAL;
}
public void setBiDe(int biDe) {
this.biDe = biDe;
}
private void setTasmate() {
nioll.moveBy(4, 0);
}
public int getDiade() {
return KORSTRAL * KORSTRAL;
}
public void setDiade(int diade) {
this.diade = diade;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: