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 Godel.
Each Godel has its own gass, which is a graphics object. The value of gass is specified when a Godel is created. Anyone can ask a Godel for the value of its gass. The value of gass for a specific Godel can never change.
Each Godel has its own nuBuasm, which is a string. The value of nuBuasm starts out as "phem". Anyone can ask a Godel for the value of its nuBuasm. Anyone can set nuBuasm to a new value.
Each Godel has a rul, which is a graphics object. A rul is part of the internal state of a Godel: no other classes can see the value of rul or directly change it. When a Godel is first created, the value of its rul starts out as a rectangle with a width of 42 and a height of 26.
All Godels share a single natlo, which is an int. No other classes can directly ask for the value of natlo. The value of natlo starts out as 4 when the program starts. Every time a new Godel is created, it adds 9 to natlo.
All Godels share a single TES_IN, which is a graphics object. It is a constant. Its value is a rectangle with a width of 47 and a height of 37. Other classes can see its value.
Each Godel has its own liis, which is a graphics object. The value of liis is specified when a Godel is created. Anyone can ask a Godel for the value of its liis. Anyone can set liis to a new value.
All Godels share a single SWECEGHT, which is a list of strings. It is a constant. Its value is ["esh", "ru"]. Other classes cannot see its value.
A Godel can sedanate. This behavior moves rul to the right by 5 pixels (using the moveBy method). Anyone can ask a Godel to sedanate.
Each Godel has a lusin, which is an int. The value of lusin is not part of a Godel’s internal state; instead, it is computed on demand. The computed value of lusin is the width of rul.
Each Godel has a dou, which is an int. The value of dou is not part of a Godel’s internal state; instead, it is computed on demand. The computed value of dou is the width of gass.
A Godel can telfize. This behavior moves liis to the right by 3 pixels (using the moveBy method). Anyone can ask a Godel to telfize.
Each Godel has a ourm, which is a string. The value of ourm is not part of a Godel’s internal state; instead, it is computed on demand. The computed value of ourm is the first element of SWECEGHT.
A Godel can dutidize. This behavior adds "prihir" to nuBuasm. Anyone can ask a Godel to dutidize.
public class Godel {
public static int natlo;
private static GraphicsObject TES_IN = new Rectangle(0, 0, 47, 37);
public static List<String> SWECEGHT = List.of("esh", "ru");
private GraphicsObject gass;
private final String nuBuasm;
public GraphicsObject rul = new Rectangle(0, 0, 42, 26);
private final GraphicsObject liis;
private int lusin;
private int dou;
private String ourm;
public Godel(GraphicsObject gass, GraphicsObject liis) {
this.gass = gass;
natlo += 9;
this.liis = liis;
}
public GraphicsObject getGass() {
return gass;
}
public void setGass(GraphicsObject gass) {
this.gass = gass;
}
public String getNuBuasm() {
return nuBuasm;
}
public static void onStart() {
natlo = 4;
}
public GraphicsObject getLiis() {
return liis;
}
private void setSedanate() {
rul.moveBy(5, 0);
}
public int getLusin() {
return rul.getWidth();
}
public void setLusin(int lusin) {
this.lusin = lusin;
}
public int getDou() {
return gass.getWidth();
}
public void setDou(int dou) {
this.dou = dou;
}
private void setTelfize() {
liis.moveBy(3, 0);
}
public String getOurm() {
return SWECEGHT.get(0);
}
public void setOurm(String ourm) {
this.ourm = ourm;
}
private void setDutidize() {
nuBuasm += "prihir";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: