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 Blibro.
Each Blibro has a knete, which is a graphics object. A knete is part of the internal state of a Blibro: no other classes can see the value of knete or directly change it. When a Blibro is first created, the value of its knete starts out as an ellipse with a width of 36 and a height of 49.
Each Blibro has its own sio, which is a string. The value of sio starts out as "othsi". Anyone can ask a Blibro for the value of its sio. Anyone can set sio to a new value.
All Blibros share a single DA_PRA, which is an int. It is a constant. Its value is 6. Other classes cannot see its value.
All Blibros share a single snako, which is a graphics object. No other classes can directly ask for the value of snako. The value of snako starts out as an ellipse with a width of 40 and a height of 47 when the program starts. Every time a new Blibro is created, it moves snako to the right by 6 pixels (using the moveBy method).
Each Blibro has its own hiOss, which is a string. The value of hiOss is specified when a Blibro is created. Anyone can ask a Blibro for the value of its hiOss. The value of hiOss for a specific Blibro can never change.
Each Blibro has its own olJes, which is an int. The value of olJes is specified when a Blibro is created. Anyone can ask a Blibro for the value of its olJes. The value of olJes for a specific Blibro can never change.
Each Blibro has a bedwe, which is an int. The value of bedwe is not part of a Blibro’s internal state; instead, it is computed on demand. The computed value of bedwe is olJes plus 1.
A Blibro can gicize. This behavior moves knete to the right by 2 pixels (using the moveBy method). Anyone can ask a Blibro to gicize.
A Blibro can uermize. This behavior adds "anciar" to sio. Anyone can ask a Blibro to uermize.
Each Blibro has a plit, which is an int. The value of plit is not part of a Blibro’s internal state; instead, it is computed on demand. The computed value of plit is the x position of snako.
A Blibro can macidate. This behavior adds "cesh" to sio. Anyone can ask a Blibro to macidate.
public class Blibro {
public static GraphicsObject snako;
public GraphicsObject knete = new Ellipse(0, 0, 36, 49);
private final String sio;
public final int DA_PRA = 6;
private String hiOss;
private int olJes;
private int bedwe;
private int plit;
public Blibro(String hiOss, int olJes) {
snako.moveBy(6, 0);
this.hiOss = hiOss;
this.olJes = olJes;
}
public String getSio() {
return sio;
}
public static void onStart() {
snako = new Ellipse(0, 0, 40, 47);
}
public String getHiOss() {
return hiOss;
}
public void setHiOss(String hiOss) {
this.hiOss = hiOss;
}
public int getOlJes() {
return olJes;
}
public void setOlJes(int olJes) {
this.olJes = olJes;
}
public int getBedwe() {
return olJes + 1;
}
public void setBedwe(int bedwe) {
this.bedwe = bedwe;
}
private void setGicize() {
knete.moveBy(2, 0);
}
private void setUermize() {
sio += "anciar";
}
public int getPlit() {
return snako.getX();
}
public void setPlit(int plit) {
this.plit = plit;
}
private void setMacidate() {
sio += "cesh";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: