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 Gruad.
Each Gruad has its own buArwig, which is a list of strings. The value of buArwig is specified when a Gruad is created. Anyone can ask a Gruad for the value of its buArwig. Anyone can set buArwig to a new value.
All Gruads share a single vaed, which is an int. No other classes can directly ask for the value of vaed. The value of vaed starts out as 9 when the program starts. Every time a new Gruad is created, it adds 1 to vaed.
All Gruads share a single NO_CLACLASS, which is a list of strings. It is a constant. Its value is ["enggnen", "shese", "dintriess"]. Other classes can see its value.
Each Gruad has its own utres, which is an int. The value of utres is specified when a Gruad is created. Anyone can ask a Gruad for the value of its utres. The value of utres for a specific Gruad can never change.
Each Gruad has a paOodpi, which is a list of strings. A paOodpi is part of the internal state of a Gruad: no other classes can see the value of paOodpi or directly change it. When a Gruad is first created, the value of its paOodpi starts out as an empty mutable list.
Each Gruad has a spe, which is a string. A spe is part of the internal state of a Gruad: no other classes can see the value of spe or directly change it. When a Gruad is first created, the value of its spe starts out as "orco".
A Gruad can nelify. This behavior adds 2 to vaed. Anyone can ask a Gruad to nelify.
Each Gruad has a bata, which is an int. The value of bata is not part of a Gruad’s internal state; instead, it is computed on demand. The computed value of bata is utres squared.
A Gruad can engtinify. This behavior adds "fimek" to paOodpi. Anyone can ask a Gruad to engtinify.
Each Gruad has a cuBie, which is an int. The value of cuBie is not part of a Gruad’s internal state; instead, it is computed on demand. The computed value of cuBie is the length of spe.
Each Gruad has a tresh, which is an int. The value of tresh is not part of a Gruad’s internal state; instead, it is computed on demand. The computed value of tresh is the size of buArwig.
public class Gruad {
public static int vaed;
private static List<String> NO_CLACLASS = List.of("enggnen", "shese", "dintriess");
private final List<String> buArwig;
private int utres;
public List<String> paOodpi = new ArrayList<>();
public String spe = "orco";
private int bata;
private int cuBie;
private int tresh;
public Gruad(List<String> buArwig, int utres) {
this.buArwig = buArwig;
vaed += 1;
this.utres = utres;
}
public List<String> getBuArwig() {
return buArwig;
}
public static void onStart() {
vaed = 9;
}
public int getUtres() {
return utres;
}
public void setUtres(int utres) {
this.utres = utres;
}
private void setNelify() {
vaed += 2;
}
public int getBata() {
return utres * utres;
}
public void setBata(int bata) {
this.bata = bata;
}
private void setEngtinify() {
paOodpi.add("fimek");
}
public int getCuBie() {
return spe.length();
}
public void setCuBie(int cuBie) {
this.cuBie = cuBie;
}
public int getTresh() {
return buArwig.size();
}
public void setTresh(int tresh) {
this.tresh = tresh;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: