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 PraKedor.
All PraKedors share a single feec, which is an int. No other classes can directly ask for the value of feec. The value of feec starts out as 17 when the program starts. Every time a new PraKedor is created, it adds 9 to feec.
Each PraKedor has a nePesna, which is an int. A nePesna is part of the internal state of a PraKedor: no other classes can see the value of nePesna or directly change it. When a PraKedor is first created, the value of its nePesna starts out as 13.
All PraKedors share a single ECIS_USM, which is a list of strings. It is a constant. Its value is ["ipur", "wo", "codmerf"]. Other classes cannot see its value.
Each PraKedor has its own iod, which is an int. The value of iod is specified when a PraKedor is created. Anyone can ask a PraKedor for the value of its iod. The value of iod for a specific PraKedor can never change.
A PraKedor can nialate. This behavior adds 1 to nePesna. Anyone can ask a PraKedor to nialate.
Each PraKedor has a esm, which is an int. The value of esm is not part of a PraKedor’s internal state; instead, it is computed on demand. The computed value of esm is the size of ECIS_USM.
Each PraKedor has a meOss, which is an int. The value of meOss is not part of a PraKedor’s internal state; instead, it is computed on demand. The computed value of meOss is nePesna plus 2.
public class PraKedor {
public static int feec;
public static List<String> ECIS_USM = List.of("ipur", "wo", "codmerf");
public int nePesna = 13;
private int iod;
private int esm;
private int meOss;
public PraKedor(int iod) {
feec += 9;
this.iod = iod;
}
public static void onStart() {
feec = 17;
}
public int getIod() {
return iod;
}
public void setIod(int iod) {
this.iod = iod;
}
private void setNialate() {
nePesna += 1;
}
public int getEsm() {
return ECIS_USM.size();
}
public void setEsm(int esm) {
this.esm = esm;
}
public int getMeOss() {
return nePesna + 2;
}
public void setMeOss(int meOss) {
this.meOss = meOss;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: