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 Nordsal.
Each Nordsal has its own pepho, which is a string. The value of pepho is specified when a Nordsal is created. Anyone can ask a Nordsal for the value of its pepho. The value of pepho for a specific Nordsal can never change.
Each Nordsal has a credu, which is an int. A credu is part of the internal state of a Nordsal: no other classes can see the value of credu or directly change it. When a Nordsal is first created, the value of its credu starts out as 17.
All Nordsals share a single DA_CLIC, which is a graphics object. It is a constant. Its value is a rectangle with a width of 42 and a height of 14. Other classes cannot see its value.
Each Nordsal has its own crak, which is a list of strings. The value of crak starts out as an empty mutable list. Anyone can ask a Nordsal for the value of its crak. Anyone can set crak to a new value.
All Nordsals share a single acha, which is a list of strings. No other classes can directly ask for the value of acha. The value of acha starts out as an empty mutable list when the program starts. Every time a new Nordsal is created, it adds "eud" to acha.
Each Nordsal has its own roirm, which is a graphics object. The value of roirm is specified when a Nordsal is created. Anyone can ask a Nordsal for the value of its roirm. The value of roirm for a specific Nordsal can never change.
All Nordsals share a single ceBrai, which is a string. No other classes can directly ask for the value of ceBrai. The value of ceBrai starts out as "nedo" when the program starts. Every time a new Nordsal is created, it adds "buedcran" to ceBrai.
All Nordsals share a single HE_SUMOU, which is a graphics object. It is a constant. Its value is a rectangle with a width of 43 and a height of 40. Other classes cannot see its value.
A Nordsal can iwingify. This behavior adds 9 to credu. Anyone can ask a Nordsal to iwingify.
Each Nordsal has a adGac, which is an int. The value of adGac is not part of a Nordsal’s internal state; instead, it is computed on demand. The computed value of adGac is the x position of DA_CLIC.
A Nordsal can sieodate. This behavior adds "vi" to acha. Anyone can ask a Nordsal to sieodate.
Each Nordsal has a olSas, which is an int. The value of olSas is not part of a Nordsal’s internal state; instead, it is computed on demand. The computed value of olSas is the x position of roirm.
A Nordsal can veunize. This behavior adds "madoa" to crak. Anyone can ask a Nordsal to veunize.
Each Nordsal has a ceth, which is an int. The value of ceth is not part of a Nordsal’s internal state; instead, it is computed on demand. The computed value of ceth is the width of HE_SUMOU.
A Nordsal can issize. This behavior adds "phiong" to ceBrai. Anyone can ask a Nordsal to issize.
public class Nordsal {
public static GraphicsObject DA_CLIC = new Rectangle(0, 0, 42, 14);
public static List<String> acha;
public static String ceBrai;
public static GraphicsObject HE_SUMOU = new Rectangle(0, 0, 43, 40);
private String pepho;
public int credu = 17;
private final List<String> crak;
private GraphicsObject roirm;
private int adGac;
private int olSas;
private int ceth;
public Nordsal(String pepho, GraphicsObject roirm) {
this.pepho = pepho;
acha.add("eud");
this.roirm = roirm;
ceBrai += "buedcran";
}
public String getPepho() {
return pepho;
}
public void setPepho(String pepho) {
this.pepho = pepho;
}
public List<String> getCrak() {
return crak;
}
public static void onStart() {
acha = new ArrayList<>();
ceBrai = "nedo";
}
public GraphicsObject getRoirm() {
return roirm;
}
public void setRoirm(GraphicsObject roirm) {
this.roirm = roirm;
}
private void setIwingify() {
credu += 9;
}
public int getAdGac() {
return DA_CLIC.getX();
}
public void setAdGac(int adGac) {
this.adGac = adGac;
}
private void setSieodate() {
acha.add("vi");
}
public int getOlSas() {
return roirm.getX();
}
public void setOlSas(int olSas) {
this.olSas = olSas;
}
private void setVeunize() {
crak.add("madoa");
}
public int getCeth() {
return HE_SUMOU.getWidth();
}
public void setCeth(int ceth) {
this.ceth = ceth;
}
private void setIssize() {
ceBrai += "phiong";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: