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 Uapri.
Each Uapri has its own wier, which is a graphics object. The value of wier is specified when a Uapri is created. Anyone can ask an Uapri for the value of its wier. The value of wier for a specific Uapri can never change.
All Uapris share a single SODKE_MONKSCOU, which is a string. It is a constant. Its value is "lioss". Other classes cannot see its value.
All Uapris share a single guc, which is an int. No other classes can directly ask for the value of guc. The value of guc starts out as 19 when the program starts. Every time a new Uapri is created, it adds 3 to guc.
Each Uapri has a cio, which is an int. A cio is part of the internal state of an Uapri: no other classes can see the value of cio or directly change it. When an Uapri is first created, the value of its cio starts out as 3.
Each Uapri has its own olan, which is a string. The value of olan starts out as "te". Anyone can ask an Uapri for the value of its olan. Anyone can set olan to a new value.
Each Uapri has a daEac, which is an int. The value of daEac is not part of an Uapri’s internal state; instead, it is computed on demand. The computed value of daEac is guc squared.
An Uapri can cecocify. This behavior adds "hepric" to olan. Anyone can ask an Uapri to cecocify.
An Uapri can blatify. This behavior adds "plian" to olan. Anyone can ask an Uapri to blatify.
Each Uapri has a ded, which is an int. The value of ded is not part of an Uapri’s internal state; instead, it is computed on demand. The computed value of ded is cio plus 2.
public class Uapri {
public static String SODKE_MONKSCOU = "lioss";
public static int guc;
private GraphicsObject wier;
public int cio = 3;
private final String olan;
private int daEac;
private int ded;
public Uapri(GraphicsObject wier) {
this.wier = wier;
guc += 3;
}
public GraphicsObject getWier() {
return wier;
}
public void setWier(GraphicsObject wier) {
this.wier = wier;
}
public static void onStart() {
guc = 19;
}
public String getOlan() {
return olan;
}
public int getDaEac() {
return guc * guc;
}
public void setDaEac(int daEac) {
this.daEac = daEac;
}
private void setCecocify() {
olan += "hepric";
}
private void setBlatify() {
olan += "plian";
}
public int getDed() {
return cio + 2;
}
public void setDed(int ded) {
this.ded = ded;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: