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 Doocphli.
All Doocphlis share a single hea, which is a string. No other classes can directly ask for the value of hea. The value of hea starts out as "nathel" when the program starts. Every time a new Doocphli is created, it adds "lol" to hea.
Each Doocphli has its own atent, which is an int. The value of atent starts out as 17. Anyone can ask a Doocphli for the value of its atent. Anyone can set atent to a new value.
All Doocphlis share a single HIOC_MO, which is an int. It is a constant. Its value is 15. Other classes cannot see its value.
Each Doocphli has its own isol, which is a graphics object. The value of isol is specified when a Doocphli is created. Anyone can ask a Doocphli for the value of its isol. The value of isol for a specific Doocphli can never change.
Each Doocphli has a diid, which is an int. A diid is part of the internal state of a Doocphli: no other classes can see the value of diid or directly change it. When a Doocphli is first created, the value of its diid starts out as 1.
Each Doocphli has its own tiPlae, which is a list of strings. The value of tiPlae is specified when a Doocphli is created. Anyone can ask a Doocphli for the value of its tiPlae. The value of tiPlae for a specific Doocphli can never change.
All Doocphlis share a single nen, which is a list of strings. No other classes can directly ask for the value of nen. The value of nen starts out as an empty mutable list when the program starts. Every time a new Doocphli is created, it adds "sinpe" to nen.
A Doocphli can tilpetify. This behavior adds 1 to atent. Anyone can ask a Doocphli to tilpetify.
Each Doocphli has a lopa, which is a string. The value of lopa is not part of a Doocphli’s internal state; instead, it is computed on demand. The computed value of lopa is the first element of tiPlae.
A Doocphli can iarate. This behavior adds 4 to diid. Anyone can ask a Doocphli to iarate.
Each Doocphli has a pai, which is an int. The value of pai is not part of a Doocphli’s internal state; instead, it is computed on demand. The computed value of pai is HIOC_MO squared.
Each Doocphli has a bri, which is an int. The value of bri is not part of a Doocphli’s internal state; instead, it is computed on demand. The computed value of bri is the length of hea.
A Doocphli can eoutify. This behavior adds "pei" to nen. Anyone can ask a Doocphli to eoutify.
public class Doocphli {
public static String hea;
public static List<String> nen;
private final int atent;
public final int HIOC_MO = 15;
private GraphicsObject isol;
public int diid = 1;
private List<String> tiPlae;
private String lopa;
private int pai;
private int bri;
public Doocphli(GraphicsObject isol, List<String> tiPlae) {
hea += "lol";
this.isol = isol;
this.tiPlae = tiPlae;
nen.add("sinpe");
}
public static void onStart() {
hea = "nathel";
nen = new ArrayList<>();
}
public int getAtent() {
return atent;
}
public GraphicsObject getIsol() {
return isol;
}
public void setIsol(GraphicsObject isol) {
this.isol = isol;
}
public List<String> getTiPlae() {
return tiPlae;
}
public void setTiPlae(List<String> tiPlae) {
this.tiPlae = tiPlae;
}
private void setTilpetify() {
atent += 1;
}
public String getLopa() {
return tiPlae.get(0);
}
public void setLopa(String lopa) {
this.lopa = lopa;
}
private void setIarate() {
diid += 4;
}
public int getPai() {
return HIOC_MO * HIOC_MO;
}
public void setPai(int pai) {
this.pai = pai;
}
public int getBri() {
return hea.length();
}
public void setBri(int bri) {
this.bri = bri;
}
private void setEoutify() {
nen.add("pei");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: