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 Montfor.
All Montfors share a single siWesh, which is a graphics object. No other classes can directly ask for the value of siWesh. The value of siWesh starts out as an ellipse with a width of 25 and a height of 27 when the program starts. Every time a new Montfor is created, it moves siWesh to the right by 3 pixels (using the moveBy method).
Each Montfor has its own hesh, which is a string. The value of hesh starts out as "e". Anyone can ask a Montfor for the value of its hesh. Anyone can set hesh to a new value.
Each Montfor has a geBepan, which is an int. A geBepan is part of the internal state of a Montfor: no other classes can see the value of geBepan or directly change it. When a Montfor is first created, the value of its geBepan starts out as 13.
All Montfors share a single GI_DASSUI, which is a string. It is a constant. Its value is "re". Other classes cannot see its value.
Each Montfor has its own sofce, which is a string. The value of sofce is specified when a Montfor is created. Anyone can ask a Montfor for the value of its sofce. The value of sofce for a specific Montfor can never change.
Each Montfor has its own crue, which is a graphics object. The value of crue is specified when a Montfor is created. Anyone can ask a Montfor for the value of its crue. The value of crue for a specific Montfor can never change.
Each Montfor has a sorre, which is a list of strings. A sorre is part of the internal state of a Montfor: no other classes can see the value of sorre or directly change it. When a Montfor is first created, the value of its sorre starts out as an empty mutable list.
Each Montfor has a hira, which is a string. The value of hira is not part of a Montfor’s internal state; instead, it is computed on demand. The computed value of hira is the first element of sorre.
A Montfor can broupify. This behavior adds "whecspreck" to sorre. Anyone can ask a Montfor to broupify.
A Montfor can bicirify. This behavior adds 3 to geBepan. Anyone can ask a Montfor to bicirify.
Each Montfor has a pra, which is a string. The value of pra is not part of a Montfor’s internal state; instead, it is computed on demand. The computed value of pra is hesh with two exclamation points appended.
Each Montfor has a ein, which is a string. The value of ein is not part of a Montfor’s internal state; instead, it is computed on demand. The computed value of ein is hesh with two exclamation points appended.
A Montfor can bexodify. This behavior adds "rerce" to hesh. Anyone can ask a Montfor to bexodify.
public class Montfor {
public static GraphicsObject siWesh;
public static String GI_DASSUI = "re";
private final String hesh;
public int geBepan = 13;
private String sofce;
private GraphicsObject crue;
public List<String> sorre = new ArrayList<>();
private String hira;
private String pra;
private String ein;
public Montfor(String sofce, GraphicsObject crue) {
siWesh.moveBy(3, 0);
this.sofce = sofce;
this.crue = crue;
}
public static void onStart() {
siWesh = new Ellipse(0, 0, 25, 27);
}
public String getHesh() {
return hesh;
}
public String getSofce() {
return sofce;
}
public void setSofce(String sofce) {
this.sofce = sofce;
}
public GraphicsObject getCrue() {
return crue;
}
public void setCrue(GraphicsObject crue) {
this.crue = crue;
}
public String getHira() {
return sorre.get(0);
}
public void setHira(String hira) {
this.hira = hira;
}
private void setBroupify() {
sorre.add("whecspreck");
}
private void setBicirify() {
geBepan += 3;
}
public String getPra() {
return hesh + "!!";
}
public void setPra(String pra) {
this.pra = pra;
}
public String getEin() {
return hesh + "!!";
}
public void setEin(String ein) {
this.ein = ein;
}
private void setBexodify() {
hesh += "rerce";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: