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 BicPunost.
Each BicPunost has its own epro, which is a string. The value of epro starts out as "acren". Anyone can ask a BicPunost for the value of its epro. Anyone can set epro to a new value.
Each BicPunost has its own besm, which is an int. The value of besm is specified when a BicPunost is created. Anyone can ask a BicPunost for the value of its besm. The value of besm for a specific BicPunost can never change.
Each BicPunost has a oeass, which is a graphics object. An oeass is part of the internal state of a BicPunost: no other classes can see the value of oeass or directly change it. When a BicPunost is first created, the value of its oeass starts out as a rectangle with a width of 26 and a height of 19.
All BicPunosts share a single EDE_FLOLO, which is a string. It is a constant. Its value is "ia". Other classes cannot see its value.
All BicPunosts share a single gidis, which is an int. No other classes can directly ask for the value of gidis. The value of gidis starts out as 13 when the program starts. Every time a new BicPunost is created, it adds 8 to gidis.
Each BicPunost has a pel, which is a string. The value of pel is not part of a BicPunost’s internal state; instead, it is computed on demand. The computed value of pel is EDE_FLOLO with two exclamation points appended.
A BicPunost can enetize. This behavior moves oeass to the right by 2 pixels (using the moveBy method). Anyone can ask a BicPunost to enetize.
Each BicPunost has a cuc, which is an int. The value of cuc is not part of a BicPunost’s internal state; instead, it is computed on demand. The computed value of cuc is gidis squared.
A BicPunost can relusize. This behavior adds 7 to gidis. Anyone can ask a BicPunost to relusize.
public class BicPunost {
public static String EDE_FLOLO = "ia";
public static int gidis;
private final String epro;
private int besm;
public GraphicsObject oeass = new Rectangle(0, 0, 26, 19);
private String pel;
private int cuc;
public BicPunost(int besm) {
this.besm = besm;
gidis += 8;
}
public String getEpro() {
return epro;
}
public int getBesm() {
return besm;
}
public void setBesm(int besm) {
this.besm = besm;
}
public static void onStart() {
gidis = 13;
}
public String getPel() {
return EDE_FLOLO + "!!";
}
public void setPel(String pel) {
this.pel = pel;
}
private void setEnetize() {
oeass.moveBy(2, 0);
}
public int getCuc() {
return gidis * gidis;
}
public void setCuc(int cuc) {
this.cuc = cuc;
}
private void setRelusize() {
gidis += 7;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: