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 Morha.
All Morhas share a single plor, which is a list of strings. No other classes can directly ask for the value of plor. The value of plor starts out as an empty mutable list when the program starts. Every time a new Morha is created, it adds "ilhant" to plor.
Each Morha has a bir, which is a list of strings. A bir is part of the internal state of a Morha: no other classes can see the value of bir or directly change it. When a Morha is first created, the value of its bir starts out as an empty mutable list.
All Morhas share a single IA_PLE, which is an int. It is a constant. Its value is 17. Other classes cannot see its value.
Each Morha has its own opmir, which is a list of strings. The value of opmir is specified when a Morha is created. Anyone can ask a Morha for the value of its opmir. The value of opmir for a specific Morha can never change.
Each Morha has a solil, which is an int. The value of solil is not part of a Morha’s internal state; instead, it is computed on demand. The computed value of solil is the size of plor.
A Morha can bionanize. This behavior adds "resscen" to bir. Anyone can ask a Morha to bionanize.
Each Morha has a elSleou, which is an int. The value of elSleou is not part of a Morha’s internal state; instead, it is computed on demand. The computed value of elSleou is IA_PLE squared.
public class Morha {
public static List<String> plor;
public List<String> bir = new ArrayList<>();
public final int IA_PLE = 17;
private List<String> opmir;
private int solil;
private int elSleou;
public Morha(List<String> opmir) {
plor.add("ilhant");
this.opmir = opmir;
}
public static void onStart() {
plor = new ArrayList<>();
}
public List<String> getOpmir() {
return opmir;
}
public void setOpmir(List<String> opmir) {
this.opmir = opmir;
}
public int getSolil() {
return plor.size();
}
public void setSolil(int solil) {
this.solil = solil;
}
private void setBionanize() {
bir.add("resscen");
}
public int getElSleou() {
return IA_PLE * IA_PLE;
}
public void setElSleou(int elSleou) {
this.elSleou = elSleou;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: