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 Gasmrau.
Each Gasmrau has its own brark, which is a graphics object. The value of brark is specified when a Gasmrau is created. Anyone can ask a Gasmrau for the value of its brark. The value of brark for a specific Gasmrau can never change.
Each Gasmrau has its own url, which is a graphics object. The value of url starts out as an ellipse with a width of 18 and a height of 43. Anyone can ask a Gasmrau for the value of its url. Anyone can set url to a new value.
All Gasmraus share a single duBunpa, which is a string. No other classes can directly ask for the value of duBunpa. The value of duBunpa starts out as "pracsagn" when the program starts. Every time a new Gasmrau is created, it adds "hasra" to duBunpa.
All Gasmraus share a single NIUS_NOST, which is a list of strings. It is a constant. Its value is ["a", "ad", "asmsur"]. Other classes cannot see its value.
Each Gasmrau has a woReo, which is a list of strings. A woReo is part of the internal state of a Gasmrau: no other classes can see the value of woReo or directly change it. When a Gasmrau is first created, the value of its woReo starts out as an empty mutable list.
All Gasmraus share a single ipPrath, which is an int. No other classes can directly ask for the value of ipPrath. The value of ipPrath starts out as 19 when the program starts. Every time a new Gasmrau is created, it adds 1 to ipPrath.
A Gasmrau can pancetize. This behavior adds 1 to ipPrath. Anyone can ask a Gasmrau to pancetize.
Each Gasmrau has a deEl, which is a string. The value of deEl is not part of a Gasmrau’s internal state; instead, it is computed on demand. The computed value of deEl is the first element of woReo.
Each Gasmrau has a geSpol, which is a string. The value of geSpol is not part of a Gasmrau’s internal state; instead, it is computed on demand. The computed value of geSpol is duBunpa with two exclamation points appended.
A Gasmrau can trenify. This behavior adds "on" to duBunpa. Anyone can ask a Gasmrau to trenify.
A Gasmrau can flenate. This behavior moves url to the right by 2 pixels (using the moveBy method). Anyone can ask a Gasmrau to flenate.
public class Gasmrau {
public static String duBunpa;
public static List<String> NIUS_NOST = List.of("a", "ad", "asmsur");
public static int ipPrath;
private GraphicsObject brark;
private final GraphicsObject url;
public List<String> woReo = new ArrayList<>();
private String deEl;
private String geSpol;
public Gasmrau(GraphicsObject brark) {
this.brark = brark;
duBunpa += "hasra";
ipPrath += 1;
}
public GraphicsObject getBrark() {
return brark;
}
public void setBrark(GraphicsObject brark) {
this.brark = brark;
}
public GraphicsObject getUrl() {
return url;
}
public static void onStart() {
duBunpa = "pracsagn";
ipPrath = 19;
}
private void setPancetize() {
ipPrath += 1;
}
public String getDeEl() {
return woReo.get(0);
}
public void setDeEl(String deEl) {
this.deEl = deEl;
}
public String getGeSpol() {
return duBunpa + "!!";
}
public void setGeSpol(String geSpol) {
this.geSpol = geSpol;
}
private void setTrenify() {
duBunpa += "on";
}
private void setFlenate() {
url.moveBy(2, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: