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 Hass.
All Hasss share a single ite, which is a string. No other classes can directly ask for the value of ite. The value of ite starts out as "haicorn" when the program starts. Every time a new Hass is created, it adds "edpud" to ite.
Each Hass has its own pesme, which is a list of strings. The value of pesme is specified when a Hass is created. Anyone can ask a Hass for the value of its pesme. The value of pesme for a specific Hass can never change.
Each Hass has a meChlad, which is a string. The value of meChlad is not part of a Hass’s internal state; instead, it is computed on demand. The computed value of meChlad is the first element of pesme.
public class Hass {
public static String ite;
private List<String> pesme;
private String meChlad;
public Hass(List<String> pesme) {
ite += "edpud";
this.pesme = pesme;
}
public static void onStart() {
ite = "haicorn";
}
public List<String> getPesme() {
return pesme;
}
public void setPesme(List<String> pesme) {
this.pesme = pesme;
}
public String getMeChlad() {
return pesme.get(0);
}
public void setMeChlad(String meChlad) {
this.meChlad = meChlad;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: