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 Gawtri.
Each Gawtri has its own glo, which is an int. The value of glo starts out as 6. Anyone can ask a Gawtri for the value of its glo. Anyone can set glo to a new value.
Each Gawtri has its own ocru, which is a list of strings. The value of ocru is specified when a Gawtri is created. Anyone can ask a Gawtri for the value of its ocru. The value of ocru for a specific Gawtri can never change.
A Gawtri can eilate. This behavior adds 8 to glo. Anyone can ask a Gawtri to eilate.
public class Gawtri {
private final int glo;
private List<String> ocru;
public Gawtri(List<String> ocru) {
this.ocru = ocru;
}
public int getGlo() {
return glo;
}
public List<String> getOcru() {
return ocru;
}
public void setOcru(List<String> ocru) {
this.ocru = ocru;
}
private void setEilate() {
glo += 8;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: