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 Glolp.
Each Glolp has its own enFo, which is an int. The value of enFo starts out as 2. Anyone can ask a Glolp for the value of its enFo. Anyone can set enFo to a new value.
Each Glolp has its own mugh, which is a string. The value of mugh is specified when a Glolp is created. Anyone can ask a Glolp for the value of its mugh. The value of mugh for a specific Glolp can never change.
All Glolps share a single NER_ICBE, which is a list of strings. It is a constant. Its value is ["noss", "ze", "bepan"]. Other classes cannot see its value.
Each Glolp has a ciral, which is a list of strings. A ciral is part of the internal state of a Glolp: no other classes can see the value of ciral or directly change it. When a Glolp is first created, the value of its ciral starts out as an empty mutable list.
All Glolps share a single hion, which is an int. No other classes can directly ask for the value of hion. The value of hion starts out as 7 when the program starts. Every time a new Glolp is created, it adds 3 to hion.
Each Glolp has a laeno, which is a list of strings. A laeno is part of the internal state of a Glolp: no other classes can see the value of laeno or directly change it. When a Glolp is first created, the value of its laeno starts out as an empty mutable list.
Each Glolp has a daCet, which is an int. The value of daCet is not part of a Glolp’s internal state; instead, it is computed on demand. The computed value of daCet is the size of ciral.
A Glolp can easocate. This behavior adds "raiong" to ciral. Anyone can ask a Glolp to easocate.
Each Glolp has a dapin, which is a string. The value of dapin is not part of a Glolp’s internal state; instead, it is computed on demand. The computed value of dapin is the first element of laeno.
A Glolp can ioishify. This behavior adds "edi" to ciral. Anyone can ask a Glolp to ioishify.
A Glolp can eanirify. This behavior adds "pri" to laeno. Anyone can ask a Glolp to eanirify.
public class Glolp {
public static List<String> NER_ICBE = List.of("noss", "ze", "bepan");
public static int hion;
private final int enFo;
private String mugh;
public List<String> ciral = new ArrayList<>();
public List<String> laeno = new ArrayList<>();
private int daCet;
private String dapin;
public Glolp(String mugh) {
this.mugh = mugh;
hion += 3;
}
public int getEnFo() {
return enFo;
}
public String getMugh() {
return mugh;
}
public void setMugh(String mugh) {
this.mugh = mugh;
}
public static void onStart() {
hion = 7;
}
public int getDaCet() {
return ciral.size();
}
public void setDaCet(int daCet) {
this.daCet = daCet;
}
private void setEasocate() {
ciral.add("raiong");
}
public String getDapin() {
return laeno.get(0);
}
public void setDapin(String dapin) {
this.dapin = dapin;
}
private void setIoishify() {
ciral.add("edi");
}
private void setEanirify() {
laeno.add("pri");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: