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 Melsess.
Each Melsess has its own fiMuc, which is a string. The value of fiMuc is specified when a Melsess is created. Anyone can ask a Melsess for the value of its fiMuc. The value of fiMuc for a specific Melsess can never change.
All Melsesss share a single CIDMUST, which is a string. It is a constant. Its value is "flempasm". Other classes cannot see its value.
Each Melsess has a sudto, which is a list of strings. A sudto is part of the internal state of a Melsess: no other classes can see the value of sudto or directly change it. When a Melsess is first created, the value of its sudto starts out as an empty mutable list.
Each Melsess has its own cung, which is a list of strings. The value of cung is specified when a Melsess is created. Anyone can ask a Melsess for the value of its cung. Anyone can set cung to a new value.
All Melsesss share a single foDa, which is a string. No other classes can directly ask for the value of foDa. The value of foDa starts out as "je" when the program starts. Every time a new Melsess is created, it adds "i" to foDa.
Each Melsess has its own vaFa, which is a graphics object. The value of vaFa is specified when a Melsess is created. Anyone can ask a Melsess for the value of its vaFa. The value of vaFa for a specific Melsess can never change.
Each Melsess has its own caHi, which is an int. The value of caHi starts out as 10. Anyone can ask a Melsess for the value of its caHi. Anyone can set caHi to a new value.
A Melsess can stecate. This behavior adds 4 to caHi. Anyone can ask a Melsess to stecate.
Each Melsess has a erSo, which is a string. The value of erSo is not part of a Melsess’s internal state; instead, it is computed on demand. The computed value of erSo is the first element of cung.
Each Melsess has a meEud, which is an int. The value of meEud is not part of a Melsess’s internal state; instead, it is computed on demand. The computed value of meEud is the width of vaFa.
A Melsess can utoonate. This behavior adds "fossphan" to cung. Anyone can ask a Melsess to utoonate.
Each Melsess has a idec, which is a string. The value of idec is not part of a Melsess’s internal state; instead, it is computed on demand. The computed value of idec is fiMuc with two exclamation points appended.
A Melsess can lursate. This behavior adds 1 to caHi. Anyone can ask a Melsess to lursate.
public class Melsess {
public static String CIDMUST = "flempasm";
public static String foDa;
private String fiMuc;
public List<String> sudto = new ArrayList<>();
private final List<String> cung;
private GraphicsObject vaFa;
private final int caHi;
private String erSo;
private int meEud;
private String idec;
public Melsess(String fiMuc, List<String> cung, GraphicsObject vaFa) {
this.fiMuc = fiMuc;
this.cung = cung;
foDa += "i";
this.vaFa = vaFa;
}
public String getFiMuc() {
return fiMuc;
}
public void setFiMuc(String fiMuc) {
this.fiMuc = fiMuc;
}
public List<String> getCung() {
return cung;
}
public static void onStart() {
foDa = "je";
}
public GraphicsObject getVaFa() {
return vaFa;
}
public void setVaFa(GraphicsObject vaFa) {
this.vaFa = vaFa;
}
public int getCaHi() {
return caHi;
}
private void setStecate() {
caHi += 4;
}
public String getErSo() {
return cung.get(0);
}
public void setErSo(String erSo) {
this.erSo = erSo;
}
public int getMeEud() {
return vaFa.getWidth();
}
public void setMeEud(int meEud) {
this.meEud = meEud;
}
private void setUtoonate() {
cung.add("fossphan");
}
public String getIdec() {
return fiMuc + "!!";
}
public void setIdec(String idec) {
this.idec = idec;
}
private void setLursate() {
caHi += 1;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: