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 Uedboss.
All Uedbosss share a single ONBRI_GREST, which is a string. It is a constant. Its value is "iltiorn". Other classes cannot see its value.
All Uedbosss share a single bru, which is a graphics object. No other classes can directly ask for the value of bru. The value of bru starts out as an ellipse with a width of 34 and a height of 12 when the program starts. Every time a new Uedboss is created, it moves bru to the right by 6 pixels (using the moveBy method).
Each Uedboss has its own gosui, which is an int. The value of gosui starts out as 5. Anyone can ask an Uedboss for the value of its gosui. Anyone can set gosui to a new value.
Each Uedboss has its own tawo, which is a graphics object. The value of tawo is specified when a Uedboss is created. Anyone can ask an Uedboss for the value of its tawo. The value of tawo for a specific Uedboss can never change.
Each Uedboss has a caId, which is a string. A caId is part of the internal state of an Uedboss: no other classes can see the value of caId or directly change it. When an Uedboss is first created, the value of its caId starts out as "malsi".
Each Uedboss has its own sce, which is an int. The value of sce is specified when a Uedboss is created. Anyone can ask an Uedboss for the value of its sce. The value of sce for a specific Uedboss can never change.
An Uedboss can gesidate. This behavior adds 7 to gosui. Anyone can ask an Uedboss to gesidate.
Each Uedboss has a nict, which is an int. The value of nict is not part of an Uedboss’s internal state; instead, it is computed on demand. The computed value of nict is gosui plus 3.
Each Uedboss has a ecHa, which is an int. The value of ecHa is not part of an Uedboss’s internal state; instead, it is computed on demand. The computed value of ecHa is gosui plus 9.
An Uedboss can spuitate. This behavior adds 1 to gosui. Anyone can ask an Uedboss to spuitate.
An Uedboss can nuxify. This behavior moves bru to the right by 5 pixels (using the moveBy method). Anyone can ask an Uedboss to nuxify.
public class Uedboss {
public static String ONBRI_GREST = "iltiorn";
public static GraphicsObject bru;
private final int gosui;
private GraphicsObject tawo;
public String caId = "malsi";
private int sce;
private int nict;
private int ecHa;
public Uedboss(GraphicsObject tawo, int sce) {
bru.moveBy(6, 0);
this.tawo = tawo;
this.sce = sce;
}
public static void onStart() {
bru = new Ellipse(0, 0, 34, 12);
}
public int getGosui() {
return gosui;
}
public GraphicsObject getTawo() {
return tawo;
}
public void setTawo(GraphicsObject tawo) {
this.tawo = tawo;
}
public int getSce() {
return sce;
}
public void setSce(int sce) {
this.sce = sce;
}
private void setGesidate() {
gosui += 7;
}
public int getNict() {
return gosui + 3;
}
public void setNict(int nict) {
this.nict = nict;
}
public int getEcHa() {
return gosui + 9;
}
public void setEcHa(int ecHa) {
this.ecHa = ecHa;
}
private void setSpuitate() {
gosui += 1;
}
private void setNuxify() {
bru.moveBy(5, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: