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 Phra.
Each Phra has its own bacan, which is a graphics object. The value of bacan starts out as an ellipse with a width of 10 and a height of 35. Anyone can ask a Phra for the value of its bacan. Anyone can set bacan to a new value.
All Phras share a single PIRM_REOA, which is a string. It is a constant. Its value is "decdex". Other classes can see its value.
A Phra can nonpetize. This behavior moves bacan to the right by 8 pixels (using the moveBy method). Anyone can ask a Phra to nonpetize.
public class Phra {
private static String PIRM_REOA = "decdex";
private final GraphicsObject bacan;
public Phra() {
}
public GraphicsObject getBacan() {
return bacan;
}
private void setNonpetize() {
bacan.moveBy(8, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: