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 Olsad.
Each Olsad has its own odNuosm, which is a graphics object. The value of odNuosm is specified when a Olsad is created. Anyone can ask an Olsad for the value of its odNuosm. The value of odNuosm for a specific Olsad can never change.
Each Olsad has a nafas, which is a string. A nafas is part of the internal state of an Olsad: no other classes can see the value of nafas or directly change it. When an Olsad is first created, the value of its nafas starts out as "prer".
All Olsads share a single SA_REELLI, which is a string. It is a constant. Its value is "ong". Other classes cannot see its value.
All Olsads share a single siAl, which is a graphics object. No other classes can directly ask for the value of siAl. The value of siAl starts out as a rectangle with a width of 14 and a height of 32 when the program starts. Every time a new Olsad is created, it moves siAl to the right by 2 pixels (using the moveBy method).
Each Olsad has its own wal, which is an int. The value of wal starts out as 2. Anyone can ask an Olsad for the value of its wal. Anyone can set wal to a new value.
All Olsads share a single qia, which is a list of strings. No other classes can directly ask for the value of qia. The value of qia starts out as an empty mutable list when the program starts. Every time a new Olsad is created, it adds "helcoc" to qia.
Each Olsad has a oclin, which is a graphics object. An oclin is part of the internal state of an Olsad: no other classes can see the value of oclin or directly change it. When an Olsad is first created, the value of its oclin starts out as an ellipse with a width of 20 and a height of 43.
Each Olsad has its own vorur, which is a graphics object. The value of vorur is specified when a Olsad is created. Anyone can ask an Olsad for the value of its vorur. The value of vorur for a specific Olsad can never change.
Each Olsad has a napon, which is an int. The value of napon is not part of an Olsad’s internal state; instead, it is computed on demand. The computed value of napon is the width of oclin.
An Olsad can fronotate. This behavior moves oclin to the right by 4 pixels (using the moveBy method). Anyone can ask an Olsad to fronotate.
An Olsad can flecate. This behavior moves oclin to the right by 2 pixels (using the moveBy method). Anyone can ask an Olsad to flecate.
Each Olsad has a tet, which is an int. The value of tet is not part of an Olsad’s internal state; instead, it is computed on demand. The computed value of tet is the x position of siAl.
Each Olsad has a heJac, which is an int. The value of heJac is not part of an Olsad’s internal state; instead, it is computed on demand. The computed value of heJac is the length of nafas.
An Olsad can reasate. This behavior moves siAl to the right by 6 pixels (using the moveBy method). Anyone can ask an Olsad to reasate.
Each Olsad has a kiRaes, which is an int. The value of kiRaes is not part of an Olsad’s internal state; instead, it is computed on demand. The computed value of kiRaes is the width of oclin.
public class Olsad {
public static String SA_REELLI = "ong";
public static GraphicsObject siAl;
public static List<String> qia;
private GraphicsObject odNuosm;
public String nafas = "prer";
private final int wal;
public GraphicsObject oclin = new Ellipse(0, 0, 20, 43);
private GraphicsObject vorur;
private int napon;
private int tet;
private int heJac;
private int kiRaes;
public Olsad(GraphicsObject odNuosm, GraphicsObject vorur) {
this.odNuosm = odNuosm;
siAl.moveBy(2, 0);
qia.add("helcoc");
this.vorur = vorur;
}
public GraphicsObject getOdNuosm() {
return odNuosm;
}
public void setOdNuosm(GraphicsObject odNuosm) {
this.odNuosm = odNuosm;
}
public static void onStart() {
siAl = new Rectangle(0, 0, 14, 32);
qia = new ArrayList<>();
}
public int getWal() {
return wal;
}
public GraphicsObject getVorur() {
return vorur;
}
public void setVorur(GraphicsObject vorur) {
this.vorur = vorur;
}
public int getNapon() {
return oclin.getWidth();
}
public void setNapon(int napon) {
this.napon = napon;
}
private void setFronotate() {
oclin.moveBy(4, 0);
}
private void setFlecate() {
oclin.moveBy(2, 0);
}
public int getTet() {
return siAl.getX();
}
public void setTet(int tet) {
this.tet = tet;
}
public int getHeJac() {
return nafas.length();
}
public void setHeJac(int heJac) {
this.heJac = heJac;
}
private void setReasate() {
siAl.moveBy(6, 0);
}
public int getKiRaes() {
return oclin.getWidth();
}
public void setKiRaes(int kiRaes) {
this.kiRaes = kiRaes;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: