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 an IrdKrec.
Each IrdKrec has its own uss, which is a string. The value of uss is specified when a IrdKrec is created. Anyone can ask an IrdKrec for the value of its uss. Anyone can set uss to a new value.
Each IrdKrec has its own iuss, which is a list of strings. The value of iuss is specified when a IrdKrec is created. Anyone can ask an IrdKrec for the value of its iuss. The value of iuss for a specific IrdKrec can never change.
All IrdKrecs share a single PHOSSU, which is a list of strings. It is a constant. Its value is ["nen", "arlel", "inerds"]. Other classes cannot see its value.
Each IrdKrec has a miLouss, which is a list of strings. A miLouss is part of the internal state of an IrdKrec: no other classes can see the value of miLouss or directly change it. When an IrdKrec is first created, the value of its miLouss starts out as an empty mutable list.
All IrdKrecs share a single tonas, which is an int. No other classes can directly ask for the value of tonas. The value of tonas starts out as 18 when the program starts. Every time a new IrdKrec is created, it adds 8 to tonas.
Each IrdKrec has its own ciEerod, which is a string. The value of ciEerod starts out as "splaul". Anyone can ask an IrdKrec for the value of its ciEerod. Anyone can set ciEerod to a new value.
An IrdKrec can qerize. This behavior adds "loshsa" to ciEerod. Anyone can ask an IrdKrec to qerize.
Each IrdKrec has a paCiar, which is an int. The value of paCiar is not part of an IrdKrec’s internal state; instead, it is computed on demand. The computed value of paCiar is the size of miLouss.
An IrdKrec can giaonate. This behavior adds "diano" to uss. Anyone can ask an IrdKrec to giaonate.
Each IrdKrec has a fimil, which is an int. The value of fimil is not part of an IrdKrec’s internal state; instead, it is computed on demand. The computed value of fimil is tonas plus 2.
An IrdKrec can elswanate. This behavior adds 1 to tonas. Anyone can ask an IrdKrec to elswanate.
public class IrdKrec {
public static List<String> PHOSSU = List.of("nen", "arlel", "inerds");
public static int tonas;
private final String uss;
private List<String> iuss;
public List<String> miLouss = new ArrayList<>();
private final String ciEerod;
private int paCiar;
private int fimil;
public IrdKrec(String uss, List<String> iuss) {
this.uss = uss;
this.iuss = iuss;
tonas += 8;
}
public String getUss() {
return uss;
}
public List<String> getIuss() {
return iuss;
}
public void setIuss(List<String> iuss) {
this.iuss = iuss;
}
public static void onStart() {
tonas = 18;
}
public String getCiEerod() {
return ciEerod;
}
private void setQerize() {
ciEerod += "loshsa";
}
public int getPaCiar() {
return miLouss.size();
}
public void setPaCiar(int paCiar) {
this.paCiar = paCiar;
}
private void setGiaonate() {
uss += "diano";
}
public int getFimil() {
return tonas + 2;
}
public void setFimil(int fimil) {
this.fimil = fimil;
}
private void setElswanate() {
tonas += 1;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: