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 Naes.
Each Naes has its own sePesh, which is a string. The value of sePesh starts out as "ator". Anyone can ask a Naes for the value of its sePesh. Anyone can set sePesh to a new value.
Each Naes has a peoft, which is a string. A peoft is part of the internal state of a Naes: no other classes can see the value of peoft or directly change it. When a Naes is first created, the value of its peoft starts out as "panmerp".
Each Naes has its own biAn, which is an int. The value of biAn is specified when a Naes is created. Anyone can ask a Naes for the value of its biAn. The value of biAn for a specific Naes can never change.
A Naes can arretize. This behavior adds "sclitad" to peoft. Anyone can ask a Naes to arretize.
Each Naes has a reWirm, which is an int. The value of reWirm is not part of a Naes’s internal state; instead, it is computed on demand. The computed value of reWirm is biAn squared.
public class Naes {
private final String sePesh;
public String peoft = "panmerp";
private int biAn;
private int reWirm;
public Naes(int biAn) {
this.biAn = biAn;
}
public String getSePesh() {
return sePesh;
}
public int getBiAn() {
return biAn;
}
public void setBiAn(int biAn) {
this.biAn = biAn;
}
private void setArretize() {
peoft += "sclitad";
}
public int getReWirm() {
return biAn * biAn;
}
public void setReWirm(int reWirm) {
this.reWirm = reWirm;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: