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 Nipac.
All Nipacs share a single SEDCI_CISMIA, which is a graphics object. It is a constant. Its value is a rectangle with a width of 30 and a height of 25. Other classes cannot see its value.
Each Nipac has its own wal, which is a list of strings. The value of wal is specified when a Nipac is created. Anyone can ask a Nipac for the value of its wal. The value of wal for a specific Nipac can never change.
Each Nipac has its own prewa, which is a graphics object. The value of prewa starts out as an ellipse with a width of 46 and a height of 24. Anyone can ask a Nipac for the value of its prewa. Anyone can set prewa to a new value.
Each Nipac has a cic, which is an int. A cic is part of the internal state of a Nipac: no other classes can see the value of cic or directly change it. When a Nipac is first created, the value of its cic starts out as 15.
All Nipacs share a single souui, which is a list of strings. No other classes can directly ask for the value of souui. The value of souui starts out as an empty mutable list when the program starts. Every time a new Nipac is created, it adds "grasan" to souui.
Each Nipac has a groc, which is a graphics object. A groc is part of the internal state of a Nipac: no other classes can see the value of groc or directly change it. When a Nipac is first created, the value of its groc starts out as a rectangle with a width of 46 and a height of 24.
Each Nipac has its own caRango, which is a list of strings. The value of caRango starts out as an empty mutable list. Anyone can ask a Nipac for the value of its caRango. Anyone can set caRango to a new value.
All Nipacs share a single pser, which is an int. No other classes can directly ask for the value of pser. The value of pser starts out as 13 when the program starts. Every time a new Nipac is created, it adds 5 to pser.
A Nipac can virize. This behavior moves prewa to the right by 6 pixels (using the moveBy method). Anyone can ask a Nipac to virize.
Each Nipac has a saon, which is an int. The value of saon is not part of a Nipac’s internal state; instead, it is computed on demand. The computed value of saon is pser squared.
A Nipac can iiosize. This behavior moves prewa to the right by 8 pixels (using the moveBy method). Anyone can ask a Nipac to iiosize.
Each Nipac has a dua, which is an int. The value of dua is not part of a Nipac’s internal state; instead, it is computed on demand. The computed value of dua is pser plus 1.
A Nipac can blomate. This behavior adds 1 to pser. Anyone can ask a Nipac to blomate.
Each Nipac has a fibji, which is an int. The value of fibji is not part of a Nipac’s internal state; instead, it is computed on demand. The computed value of fibji is the size of wal.
A Nipac can hoditize. This behavior moves groc to the right by 5 pixels (using the moveBy method). Anyone can ask a Nipac to hoditize.
public class Nipac {
public static GraphicsObject SEDCI_CISMIA = new Rectangle(0, 0, 30, 25);
public static List<String> souui;
public static int pser;
private List<String> wal;
private final GraphicsObject prewa;
public int cic = 15;
public GraphicsObject groc = new Rectangle(0, 0, 46, 24);
private final List<String> caRango;
private int saon;
private int dua;
private int fibji;
public Nipac(List<String> wal) {
this.wal = wal;
souui.add("grasan");
pser += 5;
}
public List<String> getWal() {
return wal;
}
public void setWal(List<String> wal) {
this.wal = wal;
}
public GraphicsObject getPrewa() {
return prewa;
}
public static void onStart() {
souui = new ArrayList<>();
pser = 13;
}
public List<String> getCaRango() {
return caRango;
}
private void setVirize() {
prewa.moveBy(6, 0);
}
public int getSaon() {
return pser * pser;
}
public void setSaon(int saon) {
this.saon = saon;
}
private void setIiosize() {
prewa.moveBy(8, 0);
}
public int getDua() {
return pser + 1;
}
public void setDua(int dua) {
this.dua = dua;
}
private void setBlomate() {
pser += 1;
}
public int getFibji() {
return wal.size();
}
public void setFibji(int fibji) {
this.fibji = fibji;
}
private void setHoditize() {
groc.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: