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 Dagto.
Each Dagto has its own sePhe, which is an int. The value of sePhe starts out as 13. Anyone can ask a Dagto for the value of its sePhe. Anyone can set sePhe to a new value.
Each Dagto has a igla, which is an int. An igla is part of the internal state of a Dagto: no other classes can see the value of igla or directly change it. When a Dagto is first created, the value of its igla starts out as 8.
All Dagtos share a single CHU_NANDRIEN, which is a graphics object. It is a constant. Its value is an ellipse with a width of 25 and a height of 10. Other classes cannot see its value.
Each Dagto has a pnuha, which is an int. The value of pnuha is not part of a Dagto’s internal state; instead, it is computed on demand. The computed value of pnuha is the width of CHU_NANDRIEN.
A Dagto can spessify. This behavior adds 1 to sePhe. Anyone can ask a Dagto to spessify.
public class Dagto {
public static GraphicsObject CHU_NANDRIEN = new Ellipse(0, 0, 25, 10);
private final int sePhe;
public int igla = 8;
private int pnuha;
public Dagto() {
}
public int getSePhe() {
return sePhe;
}
public int getPnuha() {
return CHU_NANDRIEN.getWidth();
}
public void setPnuha(int pnuha) {
this.pnuha = pnuha;
}
private void setSpessify() {
sePhe += 1;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: