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 Drid.
All Drids share a single SWONDWID, which is a list of strings. It is a constant. Its value is ["liouast", "armo"]. Other classes can see its value.
Each Drid has its own mulos, which is an int. The value of mulos is specified when a Drid is created. Anyone can ask a Drid for the value of its mulos. The value of mulos for a specific Drid can never change.
Each Drid has its own weHeno, which is an int. The value of weHeno starts out as 17. Anyone can ask a Drid for the value of its weHeno. Anyone can set weHeno to a new value.
All Drids share a single qac, which is a string. No other classes can directly ask for the value of qac. The value of qac starts out as "rhunge" when the program starts. Every time a new Drid is created, it adds "igel" to qac.
Each Drid has a cuc, which is an int. A cuc is part of the internal state of a Drid: no other classes can see the value of cuc or directly change it. When a Drid is first created, the value of its cuc starts out as 15.
Each Drid has a poum, which is a string. The value of poum is not part of a Drid’s internal state; instead, it is computed on demand. The computed value of poum is qac with two exclamation points appended.
A Drid can esmize. This behavior adds "rouc" to qac. Anyone can ask a Drid to esmize.
A Drid can ongify. This behavior adds 2 to weHeno. Anyone can ask a Drid to ongify.
Each Drid has a sosm, which is an int. The value of sosm is not part of a Drid’s internal state; instead, it is computed on demand. The computed value of sosm is mulos squared.
public class Drid {
private static List<String> SWONDWID = List.of("liouast", "armo");
public static String qac;
private int mulos;
private final int weHeno;
public int cuc = 15;
private String poum;
private int sosm;
public Drid(int mulos) {
this.mulos = mulos;
qac += "igel";
}
public int getMulos() {
return mulos;
}
public void setMulos(int mulos) {
this.mulos = mulos;
}
public int getWeHeno() {
return weHeno;
}
public static void onStart() {
qac = "rhunge";
}
public String getPoum() {
return qac + "!!";
}
public void setPoum(String poum) {
this.poum = poum;
}
private void setEsmize() {
qac += "rouc";
}
private void setOngify() {
weHeno += 2;
}
public int getSosm() {
return mulos * mulos;
}
public void setSosm(int sosm) {
this.sosm = sosm;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: