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 Flecha.
All Flechas share a single OBASM_SACLIOD, which is an int. It is a constant. Its value is 2. Other classes cannot see its value.
Each Flecha has a ecIca, which is a string. An ecIca is part of the internal state of a Flecha: no other classes can see the value of ecIca or directly change it. When a Flecha is first created, the value of its ecIca starts out as "mugrec".
Each Flecha has its own eaa, which is a list of strings. The value of eaa is specified when a Flecha is created. Anyone can ask a Flecha for the value of its eaa. The value of eaa for a specific Flecha can never change.
Each Flecha has its own edped, which is an int. The value of edped starts out as 7. Anyone can ask a Flecha for the value of its edped. Anyone can set edped to a new value.
All Flechas share a single monmu, which is a list of strings. No other classes can directly ask for the value of monmu. The value of monmu starts out as an empty mutable list when the program starts. Every time a new Flecha is created, it adds "dri" to monmu.
Each Flecha has a ruTo, which is an int. The value of ruTo is not part of a Flecha’s internal state; instead, it is computed on demand. The computed value of ruTo is the length of ecIca.
A Flecha can cunchify. This behavior adds "domtan" to monmu. Anyone can ask a Flecha to cunchify.
A Flecha can brenize. This behavior adds 6 to edped. Anyone can ask a Flecha to brenize.
Each Flecha has a adRol, which is a string. The value of adRol is not part of a Flecha’s internal state; instead, it is computed on demand. The computed value of adRol is the first element of monmu.
public class Flecha {
public static List<String> monmu;
public final int OBASM_SACLIOD = 2;
public String ecIca = "mugrec";
private List<String> eaa;
private final int edped;
private int ruTo;
private String adRol;
public Flecha(List<String> eaa) {
this.eaa = eaa;
monmu.add("dri");
}
public List<String> getEaa() {
return eaa;
}
public void setEaa(List<String> eaa) {
this.eaa = eaa;
}
public int getEdped() {
return edped;
}
public static void onStart() {
monmu = new ArrayList<>();
}
public int getRuTo() {
return ecIca.length();
}
public void setRuTo(int ruTo) {
this.ruTo = ruTo;
}
private void setCunchify() {
monmu.add("domtan");
}
private void setBrenize() {
edped += 6;
}
public String getAdRol() {
return monmu.get(0);
}
public void setAdRol(String adRol) {
this.adRol = adRol;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: