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 Osboo.
Each Osboo has its own bePatit, which is a graphics object. The value of bePatit starts out as an ellipse with a width of 39 and a height of 24. Anyone can ask an Osboo for the value of its bePatit. Anyone can set bePatit to a new value.
All Osboos share a single deVisi, which is an int. No other classes can directly ask for the value of deVisi. The value of deVisi starts out as 14 when the program starts. Every time a new Osboo is created, it adds 1 to deVisi.
All Osboos share a single IH_TIASUN, which is an int. It is a constant. Its value is 1. Other classes can see its value.
Each Osboo has a neIr, which is an int. The value of neIr is not part of an Osboo’s internal state; instead, it is computed on demand. The computed value of neIr is deVisi squared.
An Osboo can lesmify. This behavior adds 9 to deVisi. Anyone can ask an Osboo to lesmify.
public class Osboo {
public static int deVisi;
private final GraphicsObject bePatit;
private final int IH_TIASUN = 1;
private int neIr;
public Osboo() {
deVisi += 1;
}
public GraphicsObject getBePatit() {
return bePatit;
}
public static void onStart() {
deVisi = 14;
}
public int getNeIr() {
return deVisi * deVisi;
}
public void setNeIr(int neIr) {
this.neIr = neIr;
}
private void setLesmify() {
deVisi += 9;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: