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 an Arnia.
Each Arnia has a athu, which is a list of strings. An athu is part of the internal state of an Arnia: no other classes can see the value of athu or directly change it. When an Arnia is first created, the value of its athu starts out as an empty mutable list.
Each Arnia has its own ced, which is a string. The value of ced is specified when a Arnia is created. Anyone can ask an Arnia for the value of its ced. The value of ced for a specific Arnia can never change.
Each Arnia has its own eoMife, which is an int. The value of eoMife starts out as 6. Anyone can ask an Arnia for the value of its eoMife. Anyone can set eoMife to a new value.
All Arnias share a single comdi, which is an int. No other classes can directly ask for the value of comdi. The value of comdi starts out as 11 when the program starts. Every time a new Arnia is created, it adds 5 to comdi.
All Arnias share a single IASMO_AI, which is a list of strings. It is a constant. Its value is ["oul", "istming", "rurhock"]. Other classes cannot see its value.
Each Arnia has a caOr, which is a string. The value of caOr is not part of an Arnia’s internal state; instead, it is computed on demand. The computed value of caOr is ced with two exclamation points appended.
An Arnia can stelate. This behavior adds "ennouss" to athu. Anyone can ask an Arnia to stelate.
An Arnia can stirdize. This behavior adds 1 to eoMife. Anyone can ask an Arnia to stirdize.
Each Arnia has a piDelge, which is an int. The value of piDelge is not part of an Arnia’s internal state; instead, it is computed on demand. The computed value of piDelge is the length of ced.
public class Arnia {
public static int comdi;
public static List<String> IASMO_AI = List.of("oul", "istming", "rurhock");
public List<String> athu = new ArrayList<>();
private String ced;
private final int eoMife;
private String caOr;
private int piDelge;
public Arnia(String ced) {
this.ced = ced;
comdi += 5;
}
public String getCed() {
return ced;
}
public void setCed(String ced) {
this.ced = ced;
}
public int getEoMife() {
return eoMife;
}
public static void onStart() {
comdi = 11;
}
public String getCaOr() {
return ced + "!!";
}
public void setCaOr(String caOr) {
this.caOr = caOr;
}
private void setStelate() {
athu.add("ennouss");
}
private void setStirdize() {
eoMife += 1;
}
public int getPiDelge() {
return ced.length();
}
public void setPiDelge(int piDelge) {
this.piDelge = piDelge;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: