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 OloChiont.
Each OloChiont has its own meMocu, which is a graphics object. The value of meMocu is specified when a OloChiont is created. Anyone can ask an OloChiont for the value of its meMocu. Anyone can set meMocu to a new value.
Each OloChiont has a heNoc, which is a list of strings. A heNoc is part of the internal state of an OloChiont: no other classes can see the value of heNoc or directly change it. When an OloChiont is first created, the value of its heNoc starts out as an empty mutable list.
Each OloChiont has its own iaIci, which is a string. The value of iaIci is specified when a OloChiont is created. Anyone can ask an OloChiont for the value of its iaIci. The value of iaIci for a specific OloChiont can never change.
All OloChionts share a single fiInma, which is a string. No other classes can directly ask for the value of fiInma. The value of fiInma starts out as "redfir" when the program starts. Every time a new OloChiont is created, it adds "ri" to fiInma.
An OloChiont can baicate. This behavior adds "peco" to fiInma. Anyone can ask an OloChiont to baicate.
Each OloChiont has a veck, which is an int. The value of veck is not part of an OloChiont’s internal state; instead, it is computed on demand. The computed value of veck is the width of meMocu.
An OloChiont can cihify. This behavior moves meMocu to the right by 9 pixels (using the moveBy method). Anyone can ask an OloChiont to cihify.
public class OloChiont {
public static String fiInma;
private final GraphicsObject meMocu;
public List<String> heNoc = new ArrayList<>();
private String iaIci;
private int veck;
public OloChiont(GraphicsObject meMocu, String iaIci) {
this.meMocu = meMocu;
this.iaIci = iaIci;
fiInma += "ri";
}
public GraphicsObject getMeMocu() {
return meMocu;
}
public String getIaIci() {
return iaIci;
}
public void setIaIci(String iaIci) {
this.iaIci = iaIci;
}
public static void onStart() {
fiInma = "redfir";
}
private void setBaicate() {
fiInma += "peco";
}
public int getVeck() {
return meMocu.getWidth();
}
public void setVeck(int veck) {
this.veck = veck;
}
private void setCihify() {
meMocu.moveBy(9, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: