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 RiwCardhilk.
All RiwCardhilks share a single AN_LEUND, which is a string. It is a constant. Its value is "lesod". Other classes can see its value.
Each RiwCardhilk has a ghoc, which is a graphics object. A ghoc is part of the internal state of a RiwCardhilk: no other classes can see the value of ghoc or directly change it. When a RiwCardhilk is first created, the value of its ghoc starts out as an ellipse with a width of 25 and a height of 17.
Each RiwCardhilk has its own rir, which is a list of strings. The value of rir is specified when a RiwCardhilk is created. Anyone can ask a RiwCardhilk for the value of its rir. The value of rir for a specific RiwCardhilk can never change.
Each RiwCardhilk has a bie, which is an int. The value of bie is not part of a RiwCardhilk’s internal state; instead, it is computed on demand. The computed value of bie is the size of rir.
A RiwCardhilk can josmate. This behavior moves ghoc to the right by 8 pixels (using the moveBy method). Anyone can ask a RiwCardhilk to josmate.
public class RiwCardhilk {
private static String AN_LEUND = "lesod";
public GraphicsObject ghoc = new Ellipse(0, 0, 25, 17);
private List<String> rir;
private int bie;
public RiwCardhilk(List<String> rir) {
this.rir = rir;
}
public List<String> getRir() {
return rir;
}
public void setRir(List<String> rir) {
this.rir = rir;
}
public int getBie() {
return rir.size();
}
public void setBie(int bie) {
this.bie = bie;
}
private void setJosmate() {
ghoc.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: