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 Usmbued.
All Usmbueds share a single ewhal, which is an int. No other classes can directly ask for the value of ewhal. The value of ewhal starts out as 12 when the program starts. Every time a new Usmbued is created, it adds 2 to ewhal.
All Usmbueds share a single SCIMELS, which is an int. It is a constant. Its value is 2. Other classes can see its value.
Each Usmbued has its own ostal, which is a string. The value of ostal starts out as "a". Anyone can ask an Usmbued for the value of its ostal. Anyone can set ostal to a new value.
Each Usmbued has its own enApnar, which is an int. The value of enApnar is specified when a Usmbued is created. Anyone can ask an Usmbued for the value of its enApnar. The value of enApnar for a specific Usmbued can never change.
Each Usmbued has a groar, which is a graphics object. A groar is part of the internal state of an Usmbued: no other classes can see the value of groar or directly change it. When an Usmbued is first created, the value of its groar starts out as a rectangle with a width of 34 and a height of 10.
Each Usmbued has its own pesur, which is a list of strings. The value of pesur starts out as an empty mutable list. Anyone can ask an Usmbued for the value of its pesur. Anyone can set pesur to a new value.
Each Usmbued has a oro, which is a graphics object. An oro is part of the internal state of an Usmbued: no other classes can see the value of oro or directly change it. When an Usmbued is first created, the value of its oro starts out as a rectangle with a width of 48 and a height of 34.
Each Usmbued has its own riap, which is a graphics object. The value of riap is specified when a Usmbued is created. Anyone can ask an Usmbued for the value of its riap. The value of riap for a specific Usmbued can never change.
Each Usmbued has a swon, which is an int. The value of swon is not part of an Usmbued’s internal state; instead, it is computed on demand. The computed value of swon is SCIMELS squared.
An Usmbued can spidize. This behavior adds "erpric" to ostal. Anyone can ask an Usmbued to spidize.
An Usmbued can capinate. This behavior adds "thesh" to ostal. Anyone can ask an Usmbued to capinate.
Each Usmbued has a olNe, which is an int. The value of olNe is not part of an Usmbued’s internal state; instead, it is computed on demand. The computed value of olNe is SCIMELS squared.
Each Usmbued has a issac, which is an int. The value of issac is not part of an Usmbued’s internal state; instead, it is computed on demand. The computed value of issac is the size of pesur.
An Usmbued can befetize. This behavior moves oro to the right by 7 pixels (using the moveBy method). Anyone can ask an Usmbued to befetize.
Each Usmbued has a edNupru, which is an int. The value of edNupru is not part of an Usmbued’s internal state; instead, it is computed on demand. The computed value of edNupru is the size of pesur.
public class Usmbued {
public static int ewhal;
private final int SCIMELS = 2;
private final String ostal;
private int enApnar;
public GraphicsObject groar = new Rectangle(0, 0, 34, 10);
private final List<String> pesur;
public GraphicsObject oro = new Rectangle(0, 0, 48, 34);
private GraphicsObject riap;
private int swon;
private int olNe;
private int issac;
private int edNupru;
public Usmbued(int enApnar, GraphicsObject riap) {
ewhal += 2;
this.enApnar = enApnar;
this.riap = riap;
}
public static void onStart() {
ewhal = 12;
}
public String getOstal() {
return ostal;
}
public int getEnApnar() {
return enApnar;
}
public void setEnApnar(int enApnar) {
this.enApnar = enApnar;
}
public List<String> getPesur() {
return pesur;
}
public GraphicsObject getRiap() {
return riap;
}
public void setRiap(GraphicsObject riap) {
this.riap = riap;
}
public int getSwon() {
return SCIMELS * SCIMELS;
}
public void setSwon(int swon) {
this.swon = swon;
}
private void setSpidize() {
ostal += "erpric";
}
private void setCapinate() {
ostal += "thesh";
}
public int getOlNe() {
return SCIMELS * SCIMELS;
}
public void setOlNe(int olNe) {
this.olNe = olNe;
}
public int getIssac() {
return pesur.size();
}
public void setIssac(int issac) {
this.issac = issac;
}
private void setBefetize() {
oro.moveBy(7, 0);
}
public int getEdNupru() {
return pesur.size();
}
public void setEdNupru(int edNupru) {
this.edNupru = edNupru;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: