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 Muedon.
Each Muedon has its own oro, which is a graphics object. The value of oro is specified when a Muedon is created. Anyone can ask a Muedon for the value of its oro. The value of oro for a specific Muedon can never change.
All Muedons share a single LIOU_SHRISSUL, which is a graphics object. It is a constant. Its value is a rectangle with a width of 20 and a height of 20. Other classes cannot see its value.
Each Muedon has a erAn, which is an int. The value of erAn is not part of a Muedon’s internal state; instead, it is computed on demand. The computed value of erAn is the x position of oro.
public class Muedon {
public static GraphicsObject LIOU_SHRISSUL = new Rectangle(0, 0, 20, 20);
private GraphicsObject oro;
private int erAn;
public Muedon(GraphicsObject oro) {
this.oro = oro;
}
public GraphicsObject getOro() {
return oro;
}
public void setOro(GraphicsObject oro) {
this.oro = oro;
}
public int getErAn() {
return oro.getX();
}
public void setErAn(int erAn) {
this.erAn = erAn;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: