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 Hata.
All Hatas share a single COWSPHAN, which is a graphics object. It is a constant. Its value is an ellipse with a width of 44 and a height of 34. Other classes can see its value.
Each Hata has its own ioc, which is a string. The value of ioc is specified when a Hata is created. Anyone can ask a Hata for the value of its ioc. The value of ioc for a specific Hata can never change.
Each Hata has a iaco, which is a string. The value of iaco is not part of a Hata’s internal state; instead, it is computed on demand. The computed value of iaco is ioc with two exclamation points appended.
public class Hata {
private static GraphicsObject COWSPHAN = new Ellipse(0, 0, 44, 34);
private String ioc;
private String iaco;
public Hata(String ioc) {
this.ioc = ioc;
}
public String getIoc() {
return ioc;
}
public void setIoc(String ioc) {
this.ioc = ioc;
}
public String getIaco() {
return ioc + "!!";
}
public void setIaco(String iaco) {
this.iaco = iaco;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: