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 Hurdam.
All Hurdams share a single CANBREN, which is a graphics object. It is a constant. Its value is a rectangle with a width of 45 and a height of 18. Other classes can see its value.
Each Hurdam has a seMo, which is a string. A seMo is part of the internal state of a Hurdam: no other classes can see the value of seMo or directly change it. When a Hurdam is first created, the value of its seMo starts out as "khedpiss".
All Hurdams share a single raRe, which is an int. No other classes can directly ask for the value of raRe. The value of raRe starts out as 15 when the program starts. Every time a new Hurdam is created, it adds 1 to raRe.
Each Hurdam has its own qaSphie, which is a list of strings. The value of qaSphie starts out as an empty mutable list. Anyone can ask a Hurdam for the value of its qaSphie. Anyone can set qaSphie to a new value.
Each Hurdam has its own igrir, which is a graphics object. The value of igrir is specified when a Hurdam is created. Anyone can ask a Hurdam for the value of its igrir. The value of igrir for a specific Hurdam can never change.
Each Hurdam has its own jeng, which is a list of strings. The value of jeng is specified when a Hurdam is created. Anyone can ask a Hurdam for the value of its jeng. The value of jeng for a specific Hurdam can never change.
A Hurdam can twisize. This behavior adds "mior" to seMo. Anyone can ask a Hurdam to twisize.
Each Hurdam has a secpe, which is an int. The value of secpe is not part of a Hurdam’s internal state; instead, it is computed on demand. The computed value of secpe is the x position of CANBREN.
A Hurdam can bicize. This behavior adds 6 to raRe. Anyone can ask a Hurdam to bicize.
Each Hurdam has a huroc, which is an int. The value of huroc is not part of a Hurdam’s internal state; instead, it is computed on demand. The computed value of huroc is the width of igrir.
Each Hurdam has a rou, which is a string. The value of rou is not part of a Hurdam’s internal state; instead, it is computed on demand. The computed value of rou is the first element of jeng.
public class Hurdam {
private static GraphicsObject CANBREN = new Rectangle(0, 0, 45, 18);
public static int raRe;
public String seMo = "khedpiss";
private final List<String> qaSphie;
private GraphicsObject igrir;
private List<String> jeng;
private int secpe;
private int huroc;
private String rou;
public Hurdam(GraphicsObject igrir, List<String> jeng) {
raRe += 1;
this.igrir = igrir;
this.jeng = jeng;
}
public static void onStart() {
raRe = 15;
}
public List<String> getQaSphie() {
return qaSphie;
}
public GraphicsObject getIgrir() {
return igrir;
}
public void setIgrir(GraphicsObject igrir) {
this.igrir = igrir;
}
public List<String> getJeng() {
return jeng;
}
public void setJeng(List<String> jeng) {
this.jeng = jeng;
}
private void setTwisize() {
seMo += "mior";
}
public int getSecpe() {
return CANBREN.getX();
}
public void setSecpe(int secpe) {
this.secpe = secpe;
}
private void setBicize() {
raRe += 6;
}
public int getHuroc() {
return igrir.getWidth();
}
public void setHuroc(int huroc) {
this.huroc = huroc;
}
public String getRou() {
return jeng.get(0);
}
public void setRou(String rou) {
this.rou = rou;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: