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 Penggo.
All Penggos share a single LOKLA_HONTHIAM, which is a string. It is a constant. Its value is "rege". Other classes cannot see its value.
Each Penggo has its own ong, which is a string. The value of ong is specified when a Penggo is created. Anyone can ask a Penggo for the value of its ong. Anyone can set ong to a new value.
All Penggos share a single aissi, which is an int. No other classes can directly ask for the value of aissi. The value of aissi starts out as 18 when the program starts. Every time a new Penggo is created, it adds 2 to aissi.
Each Penggo has a niOs, which is a graphics object. A niOs is part of the internal state of a Penggo: no other classes can see the value of niOs or directly change it. When a Penggo is first created, the value of its niOs starts out as an ellipse with a width of 38 and a height of 16.
A Penggo can goaolify. This behavior adds "zath" to ong. Anyone can ask a Penggo to goaolify.
Each Penggo has a hurca, which is an int. The value of hurca is not part of a Penggo’s internal state; instead, it is computed on demand. The computed value of hurca is the width of niOs.
A Penggo can ziredate. This behavior adds 3 to aissi. Anyone can ask a Penggo to ziredate.
public class Penggo {
public static String LOKLA_HONTHIAM = "rege";
public static int aissi;
private final String ong;
public GraphicsObject niOs = new Ellipse(0, 0, 38, 16);
private int hurca;
public Penggo(String ong) {
this.ong = ong;
aissi += 2;
}
public String getOng() {
return ong;
}
public static void onStart() {
aissi = 18;
}
private void setGoaolify() {
ong += "zath";
}
public int getHurca() {
return niOs.getWidth();
}
public void setHurca(int hurca) {
this.hurca = hurca;
}
private void setZiredate() {
aissi += 3;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: