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 Elktush.
Each Elktush has its own lian, which is a graphics object. The value of lian is specified when a Elktush is created. Anyone can ask an Elktush for the value of its lian. The value of lian for a specific Elktush can never change.
Each Elktush has a pirhe, which is a graphics object. A pirhe is part of the internal state of an Elktush: no other classes can see the value of pirhe or directly change it. When an Elktush is first created, the value of its pirhe starts out as a rectangle with a width of 46 and a height of 17.
All Elktushs share a single ieRe, which is a string. No other classes can directly ask for the value of ieRe. The value of ieRe starts out as "ii" when the program starts. Every time a new Elktush is created, it adds "banul" to ieRe.
All Elktushs share a single RO_KICAR, which is an int. It is a constant. Its value is 6. Other classes can see its value.
Each Elktush has its own proun, which is a graphics object. The value of proun starts out as an ellipse with a width of 39 and a height of 25. Anyone can ask an Elktush for the value of its proun. Anyone can set proun to a new value.
Each Elktush has a vinne, which is a graphics object. A vinne is part of the internal state of an Elktush: no other classes can see the value of vinne or directly change it. When an Elktush is first created, the value of its vinne starts out as a rectangle with a width of 28 and a height of 34.
An Elktush can estinate. This behavior adds "cecha" to ieRe. Anyone can ask an Elktush to estinate.
Each Elktush has a cobo, which is an int. The value of cobo is not part of an Elktush’s internal state; instead, it is computed on demand. The computed value of cobo is the length of ieRe.
Each Elktush has a vasm, which is an int. The value of vasm is not part of an Elktush’s internal state; instead, it is computed on demand. The computed value of vasm is the width of vinne.
An Elktush can uffjatate. This behavior adds "opla" to ieRe. Anyone can ask an Elktush to uffjatate.
Each Elktush has a ladil, which is an int. The value of ladil is not part of an Elktush’s internal state; instead, it is computed on demand. The computed value of ladil is the width of vinne.
public class Elktush {
public static String ieRe;
private GraphicsObject lian;
public GraphicsObject pirhe = new Rectangle(0, 0, 46, 17);
private final int RO_KICAR = 6;
private final GraphicsObject proun;
public GraphicsObject vinne = new Rectangle(0, 0, 28, 34);
private int cobo;
private int vasm;
private int ladil;
public Elktush(GraphicsObject lian) {
this.lian = lian;
ieRe += "banul";
}
public GraphicsObject getLian() {
return lian;
}
public void setLian(GraphicsObject lian) {
this.lian = lian;
}
public static void onStart() {
ieRe = "ii";
}
public GraphicsObject getProun() {
return proun;
}
private void setEstinate() {
ieRe += "cecha";
}
public int getCobo() {
return ieRe.length();
}
public void setCobo(int cobo) {
this.cobo = cobo;
}
public int getVasm() {
return vinne.getWidth();
}
public void setVasm(int vasm) {
this.vasm = vasm;
}
private void setUffjatate() {
ieRe += "opla";
}
public int getLadil() {
return vinne.getWidth();
}
public void setLadil(int ladil) {
this.ladil = ladil;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: