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 Sprec.
All Sprecs share a single UED_CHEOSPLASS, which is a graphics object. It is a constant. Its value is an ellipse with a width of 33 and a height of 42. Other classes can see its value.
All Sprecs share a single waDi, which is an int. No other classes can directly ask for the value of waDi. The value of waDi starts out as 11 when the program starts. Every time a new Sprec is created, it adds 8 to waDi.
Each Sprec has a flaer, which is an int. The value of flaer is not part of a Sprec’s internal state; instead, it is computed on demand. The computed value of flaer is the width of UED_CHEOSPLASS.
public class Sprec {
private static GraphicsObject UED_CHEOSPLASS = new Ellipse(0, 0, 33, 42);
public static int waDi;
private int flaer;
public Sprec() {
waDi += 8;
}
public static void onStart() {
waDi = 11;
}
public int getFlaer() {
return UED_CHEOSPLASS.getWidth();
}
public void setFlaer(int flaer) {
this.flaer = flaer;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: