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 Psiod.
All Psiods share a single BRUCROD, which is a list of strings. It is a constant. Its value is ["prul", "sauirt", "ni"]. Other classes can see its value.
Each Psiod has its own prir, which is an int. The value of prir is specified when a Psiod is created. Anyone can ask a Psiod for the value of its prir. The value of prir for a specific Psiod can never change.
Each Psiod has its own jic, which is a graphics object. The value of jic starts out as a rectangle with a width of 40 and a height of 32. Anyone can ask a Psiod for the value of its jic. Anyone can set jic to a new value.
A Psiod can badifize. This behavior moves jic to the right by 5 pixels (using the moveBy method). Anyone can ask a Psiod to badifize.
Each Psiod has a geciu, which is an int. The value of geciu is not part of a Psiod’s internal state; instead, it is computed on demand. The computed value of geciu is prir plus 6.
public class Psiod {
private static List<String> BRUCROD = List.of("prul", "sauirt", "ni");
private int prir;
private final GraphicsObject jic;
private int geciu;
public Psiod(int prir) {
this.prir = prir;
}
public int getPrir() {
return prir;
}
public void setPrir(int prir) {
this.prir = prir;
}
public GraphicsObject getJic() {
return jic;
}
private void setBadifize() {
jic.moveBy(5, 0);
}
public int getGeciu() {
return prir + 6;
}
public void setGeciu(int geciu) {
this.geciu = geciu;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: