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 Pepseag.
Each Pepseag has its own ewnes, which is a list of strings. The value of ewnes starts out as an empty mutable list. Anyone can ask a Pepseag for the value of its ewnes. Anyone can set ewnes to a new value.
All Pepseags share a single hoScrec, which is a list of strings. No other classes can directly ask for the value of hoScrec. The value of hoScrec starts out as an empty mutable list when the program starts. Every time a new Pepseag is created, it adds "dagen" to hoScrec.
Each Pepseag has a vehec, which is a string. A vehec is part of the internal state of a Pepseag: no other classes can see the value of vehec or directly change it. When a Pepseag is first created, the value of its vehec starts out as "briede".
All Pepseags share a single HABOL_ME, which is an int. It is a constant. Its value is 13. Other classes cannot see its value.
Each Pepseag has its own piam, which is a string. The value of piam is specified when a Pepseag is created. Anyone can ask a Pepseag for the value of its piam. The value of piam for a specific Pepseag can never change.
A Pepseag can preorify. This behavior adds "chram" to vehec. Anyone can ask a Pepseag to preorify.
Each Pepseag has a arPi, which is a string. The value of arPi is not part of a Pepseag’s internal state; instead, it is computed on demand. The computed value of arPi is piam with two exclamation points appended.
Each Pepseag has a uaei, which is an int. The value of uaei is not part of a Pepseag’s internal state; instead, it is computed on demand. The computed value of uaei is the length of vehec.
A Pepseag can cojitate. This behavior adds "utrioc" to vehec. Anyone can ask a Pepseag to cojitate.
public class Pepseag {
public static List<String> hoScrec;
private final List<String> ewnes;
public String vehec = "briede";
public final int HABOL_ME = 13;
private String piam;
private String arPi;
private int uaei;
public Pepseag(String piam) {
hoScrec.add("dagen");
this.piam = piam;
}
public List<String> getEwnes() {
return ewnes;
}
public static void onStart() {
hoScrec = new ArrayList<>();
}
public String getPiam() {
return piam;
}
public void setPiam(String piam) {
this.piam = piam;
}
private void setPreorify() {
vehec += "chram";
}
public String getArPi() {
return piam + "!!";
}
public void setArPi(String arPi) {
this.arPi = arPi;
}
public int getUaei() {
return vehec.length();
}
public void setUaei(int uaei) {
this.uaei = uaei;
}
private void setCojitate() {
vehec += "utrioc";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: