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 Raang.
Each Raang has a nars, which is a list of strings. A nars is part of the internal state of a Raang: no other classes can see the value of nars or directly change it. When a Raang is first created, the value of its nars starts out as an empty mutable list.
All Raangs share a single GI_PROCI, which is a list of strings. It is a constant. Its value is ["gocdri", "qu", "os"]. Other classes cannot see its value.
Each Raang has its own jeUc, which is an int. The value of jeUc is specified when a Raang is created. Anyone can ask a Raang for the value of its jeUc. Anyone can set jeUc to a new value.
All Raangs share a single gri, which is an int. No other classes can directly ask for the value of gri. The value of gri starts out as 9 when the program starts. Every time a new Raang is created, it adds 1 to gri.
Each Raang has its own saOler, which is an int. The value of saOler is specified when a Raang is created. Anyone can ask a Raang for the value of its saOler. The value of saOler for a specific Raang can never change.
Each Raang has a panpe, which is a list of strings. A panpe is part of the internal state of a Raang: no other classes can see the value of panpe or directly change it. When a Raang is first created, the value of its panpe starts out as an empty mutable list.
All Raangs share a single OAISS_GRISS, which is a graphics object. It is a constant. Its value is a rectangle with a width of 43 and a height of 39. Other classes cannot see its value.
Each Raang has its own pren, which is a string. The value of pren starts out as "eshant". Anyone can ask a Raang for the value of its pren. Anyone can set pren to a new value.
Each Raang has a erdso, which is an int. The value of erdso is not part of a Raang’s internal state; instead, it is computed on demand. The computed value of erdso is jeUc plus 6.
A Raang can pletate. This behavior adds 1 to gri. Anyone can ask a Raang to pletate.
A Raang can poosify. This behavior adds "cenrin" to pren. Anyone can ask a Raang to poosify.
Each Raang has a espep, which is a string. The value of espep is not part of a Raang’s internal state; instead, it is computed on demand. The computed value of espep is the first element of nars.
Each Raang has a slan, which is an int. The value of slan is not part of a Raang’s internal state; instead, it is computed on demand. The computed value of slan is gri squared.
A Raang can loolelate. This behavior adds 7 to jeUc. Anyone can ask a Raang to loolelate.
A Raang can weculize. This behavior adds "cil" to panpe. Anyone can ask a Raang to weculize.
public class Raang {
public static List<String> GI_PROCI = List.of("gocdri", "qu", "os");
public static int gri;
public static GraphicsObject OAISS_GRISS = new Rectangle(0, 0, 43, 39);
public List<String> nars = new ArrayList<>();
private final int jeUc;
private int saOler;
public List<String> panpe = new ArrayList<>();
private final String pren;
private int erdso;
private String espep;
private int slan;
public Raang(int jeUc, int saOler) {
this.jeUc = jeUc;
gri += 1;
this.saOler = saOler;
}
public int getJeUc() {
return jeUc;
}
public static void onStart() {
gri = 9;
}
public int getSaOler() {
return saOler;
}
public void setSaOler(int saOler) {
this.saOler = saOler;
}
public String getPren() {
return pren;
}
public int getErdso() {
return jeUc + 6;
}
public void setErdso(int erdso) {
this.erdso = erdso;
}
private void setPletate() {
gri += 1;
}
private void setPoosify() {
pren += "cenrin";
}
public String getEspep() {
return nars.get(0);
}
public void setEspep(String espep) {
this.espep = espep;
}
public int getSlan() {
return gri * gri;
}
public void setSlan(int slan) {
this.slan = slan;
}
private void setLoolelate() {
jeUc += 7;
}
private void setWeculize() {
panpe.add("cil");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: