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 Heese.
Each Heese has its own oun, which is a graphics object. The value of oun is specified when a Heese is created. Anyone can ask a Heese for the value of its oun. Anyone can set oun to a new value.
All Heeses share a single TUSHEOUL, which is a graphics object. It is a constant. Its value is an ellipse with a width of 49 and a height of 20. Other classes cannot see its value.
Each Heese has a meNirde, which is an int. A meNirde is part of the internal state of a Heese: no other classes can see the value of meNirde or directly change it. When a Heese is first created, the value of its meNirde starts out as 17.
All Heeses share a single bil, which is a string. No other classes can directly ask for the value of bil. The value of bil starts out as "dudid" when the program starts. Every time a new Heese is created, it adds "pioun" to bil.
Each Heese has its own ioEe, which is a graphics object. The value of ioEe is specified when a Heese is created. Anyone can ask a Heese for the value of its ioEe. The value of ioEe for a specific Heese can never change.
All Heeses share a single erir, which is a list of strings. No other classes can directly ask for the value of erir. The value of erir starts out as an empty mutable list when the program starts. Every time a new Heese is created, it adds "tongsi" to erir.
A Heese can pidify. This behavior moves oun to the right by 4 pixels (using the moveBy method). Anyone can ask a Heese to pidify.
Each Heese has a naCergi, which is an int. The value of naCergi is not part of a Heese’s internal state; instead, it is computed on demand. The computed value of naCergi is the x position of oun.
Each Heese has a sti, which is an int. The value of sti is not part of a Heese’s internal state; instead, it is computed on demand. The computed value of sti is the x position of ioEe.
A Heese can khoqulate. This behavior adds "riasspan" to erir. Anyone can ask a Heese to khoqulate.
Each Heese has a maOrouc, which is an int. The value of maOrouc is not part of a Heese’s internal state; instead, it is computed on demand. The computed value of maOrouc is the width of TUSHEOUL.
public class Heese {
public static GraphicsObject TUSHEOUL = new Ellipse(0, 0, 49, 20);
public static String bil;
public static List<String> erir;
private final GraphicsObject oun;
public int meNirde = 17;
private GraphicsObject ioEe;
private int naCergi;
private int sti;
private int maOrouc;
public Heese(GraphicsObject oun, GraphicsObject ioEe) {
this.oun = oun;
bil += "pioun";
this.ioEe = ioEe;
erir.add("tongsi");
}
public GraphicsObject getOun() {
return oun;
}
public static void onStart() {
bil = "dudid";
erir = new ArrayList<>();
}
public GraphicsObject getIoEe() {
return ioEe;
}
public void setIoEe(GraphicsObject ioEe) {
this.ioEe = ioEe;
}
private void setPidify() {
oun.moveBy(4, 0);
}
public int getNaCergi() {
return oun.getX();
}
public void setNaCergi(int naCergi) {
this.naCergi = naCergi;
}
public int getSti() {
return ioEe.getX();
}
public void setSti(int sti) {
this.sti = sti;
}
private void setKhoqulate() {
erir.add("riasspan");
}
public int getMaOrouc() {
return TUSHEOUL.getWidth();
}
public void setMaOrouc(int maOrouc) {
this.maOrouc = maOrouc;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: