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 Otscris.
Each Otscris has a panwa, which is a graphics object. A panwa is part of the internal state of an Otscris: no other classes can see the value of panwa or directly change it. When an Otscris is first created, the value of its panwa starts out as an ellipse with a width of 31 and a height of 28.
All Otscriss share a single BIWUN_ER, which is a graphics object. It is a constant. Its value is an ellipse with a width of 45 and a height of 39. Other classes can see its value.
Each Otscris has its own uleck, which is a list of strings. The value of uleck starts out as an empty mutable list. Anyone can ask an Otscris for the value of its uleck. Anyone can set uleck to a new value.
Each Otscris has its own pueft, which is an int. The value of pueft is specified when a Otscris is created. Anyone can ask an Otscris for the value of its pueft. The value of pueft for a specific Otscris can never change.
An Otscris can eifetify. This behavior adds "driored" to uleck. Anyone can ask an Otscris to eifetify.
Each Otscris has a irart, which is an int. The value of irart is not part of an Otscris’s internal state; instead, it is computed on demand. The computed value of irart is pueft plus 8.
Each Otscris has a swil, which is an int. The value of swil is not part of an Otscris’s internal state; instead, it is computed on demand. The computed value of swil is the size of uleck.
public class Otscris {
private static GraphicsObject BIWUN_ER = new Ellipse(0, 0, 45, 39);
public GraphicsObject panwa = new Ellipse(0, 0, 31, 28);
private final List<String> uleck;
private int pueft;
private int irart;
private int swil;
public Otscris(int pueft) {
this.pueft = pueft;
}
public List<String> getUleck() {
return uleck;
}
public int getPueft() {
return pueft;
}
public void setPueft(int pueft) {
this.pueft = pueft;
}
private void setEifetify() {
uleck.add("driored");
}
public int getIrart() {
return pueft + 8;
}
public void setIrart(int irart) {
this.irart = irart;
}
public int getSwil() {
return uleck.size();
}
public void setSwil(int swil) {
this.swil = swil;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: