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 Osun.
Each Osun has a swin, which is a string. A swin is part of the internal state of an Osun: no other classes can see the value of swin or directly change it. When an Osun is first created, the value of its swin starts out as "earpse".
All Osuns share a single treli, which is a graphics object. No other classes can directly ask for the value of treli. The value of treli starts out as an ellipse with a width of 24 and a height of 45 when the program starts. Every time a new Osun is created, it moves treli to the right by 5 pixels (using the moveBy method).
Each Osun has a qoEvar, which is an int. The value of qoEvar is not part of an Osun’s internal state; instead, it is computed on demand. The computed value of qoEvar is the x position of treli.
public class Osun {
public static GraphicsObject treli;
public String swin = "earpse";
private int qoEvar;
public Osun() {
treli.moveBy(5, 0);
}
public static void onStart() {
treli = new Ellipse(0, 0, 24, 45);
}
public int getQoEvar() {
return treli.getX();
}
public void setQoEvar(int qoEvar) {
this.qoEvar = qoEvar;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: