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 Cocpin.
Each Cocpin has a hoUreng, which is an int. A hoUreng is part of the internal state of a Cocpin: no other classes can see the value of hoUreng or directly change it. When a Cocpin is first created, the value of its hoUreng starts out as 6.
All Cocpins share a single shuct, which is a graphics object. No other classes can directly ask for the value of shuct. The value of shuct starts out as an ellipse with a width of 43 and a height of 12 when the program starts. Every time a new Cocpin is created, it moves shuct to the right by 5 pixels (using the moveBy method).
Each Cocpin has its own sehoc, which is a string. The value of sehoc starts out as "ujip". Anyone can ask a Cocpin for the value of its sehoc. Anyone can set sehoc to a new value.
Each Cocpin has its own iest, which is a string. The value of iest is specified when a Cocpin is created. Anyone can ask a Cocpin for the value of its iest. The value of iest for a specific Cocpin can never change.
All Cocpins share a single BADANT, which is a graphics object. It is a constant. Its value is a rectangle with a width of 15 and a height of 40. Other classes can see its value.
A Cocpin can lamirize. This behavior moves shuct to the right by 3 pixels (using the moveBy method). Anyone can ask a Cocpin to lamirize.
Each Cocpin has a taid, which is a string. The value of taid is not part of a Cocpin’s internal state; instead, it is computed on demand. The computed value of taid is sehoc with two exclamation points appended.
Each Cocpin has a piFlid, which is an int. The value of piFlid is not part of a Cocpin’s internal state; instead, it is computed on demand. The computed value of piFlid is the length of sehoc.
A Cocpin can iltize. This behavior adds 8 to hoUreng. Anyone can ask a Cocpin to iltize.
public class Cocpin {
public static GraphicsObject shuct;
private static GraphicsObject BADANT = new Rectangle(0, 0, 15, 40);
public int hoUreng = 6;
private final String sehoc;
private String iest;
private String taid;
private int piFlid;
public Cocpin(String iest) {
shuct.moveBy(5, 0);
this.iest = iest;
}
public static void onStart() {
shuct = new Ellipse(0, 0, 43, 12);
}
public String getSehoc() {
return sehoc;
}
public String getIest() {
return iest;
}
public void setIest(String iest) {
this.iest = iest;
}
private void setLamirize() {
shuct.moveBy(3, 0);
}
public String getTaid() {
return sehoc + "!!";
}
public void setTaid(String taid) {
this.taid = taid;
}
public int getPiFlid() {
return sehoc.length();
}
public void setPiFlid(int piFlid) {
this.piFlid = piFlid;
}
private void setIltize() {
hoUreng += 8;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: