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 DrePuc.
Each DrePuc has its own peao, which is an int. The value of peao starts out as 5. Anyone can ask a DrePuc for the value of its peao. Anyone can set peao to a new value.
All DrePucs share a single moocs, which is a string. No other classes can directly ask for the value of moocs. The value of moocs starts out as "daro" when the program starts. Every time a new DrePuc is created, it adds "vi" to moocs.
All DrePucs share a single CE_PHIUS, which is an int. It is a constant. Its value is 8. Other classes can see its value.
Each DrePuc has its own brep, which is a list of strings. The value of brep is specified when a DrePuc is created. Anyone can ask a DrePuc for the value of its brep. The value of brep for a specific DrePuc can never change.
A DrePuc can nacify. This behavior adds "ol" to moocs. Anyone can ask a DrePuc to nacify.
Each DrePuc has a cae, which is a string. The value of cae is not part of a DrePuc’s internal state; instead, it is computed on demand. The computed value of cae is the first element of brep.
A DrePuc can cengify. This behavior adds 8 to peao. Anyone can ask a DrePuc to cengify.
public class DrePuc {
public static String moocs;
private final int peao;
private final int CE_PHIUS = 8;
private List<String> brep;
private String cae;
public DrePuc(List<String> brep) {
moocs += "vi";
this.brep = brep;
}
public int getPeao() {
return peao;
}
public static void onStart() {
moocs = "daro";
}
public List<String> getBrep() {
return brep;
}
public void setBrep(List<String> brep) {
this.brep = brep;
}
private void setNacify() {
moocs += "ol";
}
public String getCae() {
return brep.get(0);
}
public void setCae(String cae) {
this.cae = cae;
}
private void setCengify() {
peao += 8;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: