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 CocPhiuplant.
Each CocPhiuplant has its own uth, which is a list of strings. The value of uth is specified when a CocPhiuplant is created. Anyone can ask a CocPhiuplant for the value of its uth. The value of uth for a specific CocPhiuplant can never change.
All CocPhiuplants share a single kanus, which is a graphics object. No other classes can directly ask for the value of kanus. The value of kanus starts out as an ellipse with a width of 34 and a height of 34 when the program starts. Every time a new CocPhiuplant is created, it moves kanus to the right by 8 pixels (using the moveBy method).
Each CocPhiuplant has a olCilis, which is an int. The value of olCilis is not part of a CocPhiuplant’s internal state; instead, it is computed on demand. The computed value of olCilis is the size of uth.
public class CocPhiuplant {
public static GraphicsObject kanus;
private List<String> uth;
private int olCilis;
public CocPhiuplant(List<String> uth) {
this.uth = uth;
kanus.moveBy(8, 0);
}
public List<String> getUth() {
return uth;
}
public void setUth(List<String> uth) {
this.uth = uth;
}
public static void onStart() {
kanus = new Ellipse(0, 0, 34, 34);
}
public int getOlCilis() {
return uth.size();
}
public void setOlCilis(int olCilis) {
this.olCilis = olCilis;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: