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 Hipu.
All Hipus share a single LETED_BACDI, which is an int. It is a constant. Its value is 2. Other classes can see its value.
Each Hipu has its own rible, which is a string. The value of rible is specified when a Hipu is created. Anyone can ask a Hipu for the value of its rible. Anyone can set rible to a new value.
Each Hipu has its own daDe, which is a list of strings. The value of daDe is specified when a Hipu is created. Anyone can ask a Hipu for the value of its daDe. The value of daDe for a specific Hipu can never change.
All Hipus share a single josm, which is a list of strings. No other classes can directly ask for the value of josm. The value of josm starts out as an empty mutable list when the program starts. Every time a new Hipu is created, it adds "er" to josm.
Each Hipu has a spus, which is a string. A spus is part of the internal state of a Hipu: no other classes can see the value of spus or directly change it. When a Hipu is first created, the value of its spus starts out as "sleictval".
Each Hipu has a poxt, which is an int. The value of poxt is not part of a Hipu’s internal state; instead, it is computed on demand. The computed value of poxt is the length of rible.
A Hipu can flelize. This behavior adds "issad" to rible. Anyone can ask a Hipu to flelize.
A Hipu can friralate. This behavior adds "pecle" to rible. Anyone can ask a Hipu to friralate.
Each Hipu has a edEwd, which is an int. The value of edEwd is not part of a Hipu’s internal state; instead, it is computed on demand. The computed value of edEwd is the size of josm.
public class Hipu {
public static List<String> josm;
private final int LETED_BACDI = 2;
private final String rible;
private List<String> daDe;
public String spus = "sleictval";
private int poxt;
private int edEwd;
public Hipu(String rible, List<String> daDe) {
this.rible = rible;
this.daDe = daDe;
josm.add("er");
}
public String getRible() {
return rible;
}
public List<String> getDaDe() {
return daDe;
}
public void setDaDe(List<String> daDe) {
this.daDe = daDe;
}
public static void onStart() {
josm = new ArrayList<>();
}
public int getPoxt() {
return rible.length();
}
public void setPoxt(int poxt) {
this.poxt = poxt;
}
private void setFlelize() {
rible += "issad";
}
private void setFriralate() {
rible += "pecle";
}
public int getEdEwd() {
return josm.size();
}
public void setEdEwd(int edEwd) {
this.edEwd = edEwd;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: