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 Didgoth.
Each Didgoth has a mial, which is a string. A mial is part of the internal state of a Didgoth: no other classes can see the value of mial or directly change it. When a Didgoth is first created, the value of its mial starts out as "poxme".
Each Didgoth has its own pread, which is an int. The value of pread is specified when a Didgoth is created. Anyone can ask a Didgoth for the value of its pread. The value of pread for a specific Didgoth can never change.
Each Didgoth has its own snon, which is a graphics object. The value of snon starts out as an ellipse with a width of 31 and a height of 46. Anyone can ask a Didgoth for the value of its snon. Anyone can set snon to a new value.
All Didgoths share a single sca, which is an int. No other classes can directly ask for the value of sca. The value of sca starts out as 7 when the program starts. Every time a new Didgoth is created, it adds 6 to sca.
All Didgoths share a single EAMI_ISMFENT, which is a string. It is a constant. Its value is "danming". Other classes cannot see its value.
Each Didgoth has a ecse, which is an int. The value of ecse is not part of a Didgoth’s internal state; instead, it is computed on demand. The computed value of ecse is the x position of snon.
A Didgoth can trelize. This behavior moves snon to the right by 3 pixels (using the moveBy method). Anyone can ask a Didgoth to trelize.
A Didgoth can dronize. This behavior moves snon to the right by 1 pixels (using the moveBy method). Anyone can ask a Didgoth to dronize.
Each Didgoth has a peOfa, which is an int. The value of peOfa is not part of a Didgoth’s internal state; instead, it is computed on demand. The computed value of peOfa is the length of mial.
public class Didgoth {
public static int sca;
public static String EAMI_ISMFENT = "danming";
public String mial = "poxme";
private int pread;
private final GraphicsObject snon;
private int ecse;
private int peOfa;
public Didgoth(int pread) {
this.pread = pread;
sca += 6;
}
public int getPread() {
return pread;
}
public void setPread(int pread) {
this.pread = pread;
}
public GraphicsObject getSnon() {
return snon;
}
public static void onStart() {
sca = 7;
}
public int getEcse() {
return snon.getX();
}
public void setEcse(int ecse) {
this.ecse = ecse;
}
private void setTrelize() {
snon.moveBy(3, 0);
}
private void setDronize() {
snon.moveBy(1, 0);
}
public int getPeOfa() {
return mial.length();
}
public void setPeOfa(int peOfa) {
this.peOfa = peOfa;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: