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 PocCoass.
Each PocCoass has its own erTriro, which is an int. The value of erTriro is specified when a PocCoass is created. Anyone can ask a PocCoass for the value of its erTriro. Anyone can set erTriro to a new value.
Each PocCoass has its own pahu, which is an int. The value of pahu is specified when a PocCoass is created. Anyone can ask a PocCoass for the value of its pahu. The value of pahu for a specific PocCoass can never change.
Each PocCoass has a gac, which is a list of strings. A gac is part of the internal state of a PocCoass: no other classes can see the value of gac or directly change it. When a PocCoass is first created, the value of its gac starts out as an empty mutable list.
All PocCoasss share a single LERNPHRAL, which is a string. It is a constant. Its value is "utja". Other classes cannot see its value.
Each PocCoass has a farho, which is an int. The value of farho is not part of a PocCoass’s internal state; instead, it is computed on demand. The computed value of farho is the length of LERNPHRAL.
A PocCoass can taditize. This behavior adds "sa" to gac. Anyone can ask a PocCoass to taditize.
A PocCoass can qetanify. This behavior adds 8 to erTriro. Anyone can ask a PocCoass to qetanify.
public class PocCoass {
public static String LERNPHRAL = "utja";
private final int erTriro;
private int pahu;
public List<String> gac = new ArrayList<>();
private int farho;
public PocCoass(int erTriro, int pahu) {
this.erTriro = erTriro;
this.pahu = pahu;
}
public int getErTriro() {
return erTriro;
}
public int getPahu() {
return pahu;
}
public void setPahu(int pahu) {
this.pahu = pahu;
}
public int getFarho() {
return LERNPHRAL.length();
}
public void setFarho(int farho) {
this.farho = farho;
}
private void setTaditize() {
gac.add("sa");
}
private void setQetanify() {
erTriro += 8;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: