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 Bandig.
Each Bandig has its own hopae, which is a graphics object. The value of hopae is specified when a Bandig is created. Anyone can ask a Bandig for the value of its hopae. Anyone can set hopae to a new value.
All Bandigs share a single crar, which is a graphics object. No other classes can directly ask for the value of crar. The value of crar starts out as a rectangle with a width of 13 and a height of 49 when the program starts. Every time a new Bandig is created, it moves crar to the right by 5 pixels (using the moveBy method).
All Bandigs share a single OODPHIA, which is an int. It is a constant. Its value is 14. Other classes cannot see its value.
Each Bandig has a dashu, which is an int. A dashu is part of the internal state of a Bandig: no other classes can see the value of dashu or directly change it. When a Bandig is first created, the value of its dashu starts out as 19.
Each Bandig has its own gaDe, which is a string. The value of gaDe is specified when a Bandig is created. Anyone can ask a Bandig for the value of its gaDe. The value of gaDe for a specific Bandig can never change.
Each Bandig has a odVeun, which is an int. An odVeun is part of the internal state of a Bandig: no other classes can see the value of odVeun or directly change it. When a Bandig is first created, the value of its odVeun starts out as 4.
All Bandigs share a single SIMB_RAUS, which is a string. It is a constant. Its value is "tre". Other classes cannot see its value.
Each Bandig has a jash, which is a string. The value of jash is not part of a Bandig’s internal state; instead, it is computed on demand. The computed value of jash is gaDe with two exclamation points appended.
A Bandig can iiatize. This behavior adds 2 to odVeun. Anyone can ask a Bandig to iiatize.
A Bandig can jangate. This behavior moves crar to the right by 2 pixels (using the moveBy method). Anyone can ask a Bandig to jangate.
Each Bandig has a renic, which is an int. The value of renic is not part of a Bandig’s internal state; instead, it is computed on demand. The computed value of renic is the length of gaDe.
Each Bandig has a ouset, which is an int. The value of ouset is not part of a Bandig’s internal state; instead, it is computed on demand. The computed value of ouset is odVeun squared.
A Bandig can esagate. This behavior moves crar to the right by 7 pixels (using the moveBy method). Anyone can ask a Bandig to esagate.
public class Bandig {
public static GraphicsObject crar;
public static String SIMB_RAUS = "tre";
private final GraphicsObject hopae;
public final int OODPHIA = 14;
public int dashu = 19;
private String gaDe;
public int odVeun = 4;
private String jash;
private int renic;
private int ouset;
public Bandig(GraphicsObject hopae, String gaDe) {
this.hopae = hopae;
crar.moveBy(5, 0);
this.gaDe = gaDe;
}
public GraphicsObject getHopae() {
return hopae;
}
public static void onStart() {
crar = new Rectangle(0, 0, 13, 49);
}
public String getGaDe() {
return gaDe;
}
public void setGaDe(String gaDe) {
this.gaDe = gaDe;
}
public String getJash() {
return gaDe + "!!";
}
public void setJash(String jash) {
this.jash = jash;
}
private void setIiatize() {
odVeun += 2;
}
private void setJangate() {
crar.moveBy(2, 0);
}
public int getRenic() {
return gaDe.length();
}
public void setRenic(int renic) {
this.renic = renic;
}
public int getOuset() {
return odVeun * odVeun;
}
public void setOuset(int ouset) {
this.ouset = ouset;
}
private void setEsagate() {
crar.moveBy(7, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: