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 Eengcar.
Each Eengcar has its own sanna, which is a graphics object. The value of sanna is specified when a Eengcar is created. Anyone can ask an Eengcar for the value of its sanna. The value of sanna for a specific Eengcar can never change.
All Eengcars share a single adil, which is a graphics object. No other classes can directly ask for the value of adil. The value of adil starts out as a rectangle with a width of 16 and a height of 42 when the program starts. Every time a new Eengcar is created, it moves adil to the right by 1 pixels (using the moveBy method).
All Eengcars share a single PRANTNILL, which is an int. It is a constant. Its value is 17. Other classes cannot see its value.
Each Eengcar has its own liRavod, which is a string. The value of liRavod starts out as "woorbeo". Anyone can ask an Eengcar for the value of its liRavod. Anyone can set liRavod to a new value.
An Eengcar can brenatize. This behavior adds "ciapco" to liRavod. Anyone can ask an Eengcar to brenatize.
Each Eengcar has a zulat, which is an int. The value of zulat is not part of an Eengcar’s internal state; instead, it is computed on demand. The computed value of zulat is the width of adil.
Each Eengcar has a ouNoora, which is an int. The value of ouNoora is not part of an Eengcar’s internal state; instead, it is computed on demand. The computed value of ouNoora is PRANTNILL squared.
public class Eengcar {
public static GraphicsObject adil;
private GraphicsObject sanna;
public final int PRANTNILL = 17;
private final String liRavod;
private int zulat;
private int ouNoora;
public Eengcar(GraphicsObject sanna) {
this.sanna = sanna;
adil.moveBy(1, 0);
}
public GraphicsObject getSanna() {
return sanna;
}
public void setSanna(GraphicsObject sanna) {
this.sanna = sanna;
}
public static void onStart() {
adil = new Rectangle(0, 0, 16, 42);
}
public String getLiRavod() {
return liRavod;
}
private void setBrenatize() {
liRavod += "ciapco";
}
public int getZulat() {
return adil.getWidth();
}
public void setZulat(int zulat) {
this.zulat = zulat;
}
public int getOuNoora() {
return PRANTNILL * PRANTNILL;
}
public void setOuNoora(int ouNoora) {
this.ouNoora = ouNoora;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: