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 Acfratch.
Each Acfratch has its own gaMaa, which is an int. The value of gaMaa is specified when a Acfratch is created. Anyone can ask an Acfratch for the value of its gaMaa. Anyone can set gaMaa to a new value.
All Acfratchs share a single PSONGHESM, which is a graphics object. It is a constant. Its value is an ellipse with a width of 21 and a height of 43. Other classes can see its value.
Each Acfratch has a ghid, which is an int. The value of ghid is not part of an Acfratch’s internal state; instead, it is computed on demand. The computed value of ghid is the width of PSONGHESM.
public class Acfratch {
private static GraphicsObject PSONGHESM = new Ellipse(0, 0, 21, 43);
private final int gaMaa;
private int ghid;
public Acfratch(int gaMaa) {
this.gaMaa = gaMaa;
}
public int getGaMaa() {
return gaMaa;
}
public int getGhid() {
return PSONGHESM.getWidth();
}
public void setGhid(int ghid) {
this.ghid = ghid;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: