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 Iwnspards.
Each Iwnspards has its own asPi, which is a list of strings. The value of asPi is specified when a Iwnspards is created. Anyone can ask an Iwnspards for the value of its asPi. The value of asPi for a specific Iwnspards can never change.
Each Iwnspards has a roPlas, which is a graphics object. A roPlas is part of the internal state of an Iwnspards: no other classes can see the value of roPlas or directly change it. When an Iwnspards is first created, the value of its roPlas starts out as a rectangle with a width of 42 and a height of 42.
Each Iwnspards has its own saUanu, which is a string. The value of saUanu starts out as "in". Anyone can ask an Iwnspards for the value of its saUanu. Anyone can set saUanu to a new value.
All Iwnspardss share a single guse, which is an int. No other classes can directly ask for the value of guse. The value of guse starts out as 5 when the program starts. Every time a new Iwnspards is created, it adds 7 to guse.
All Iwnspardss share a single KOIA_IEMPPE, which is a string. It is a constant. Its value is "oi". Other classes cannot see its value.
Each Iwnspards has its own sqe, which is an int. The value of sqe is specified when a Iwnspards is created. Anyone can ask an Iwnspards for the value of its sqe. The value of sqe for a specific Iwnspards can never change.
An Iwnspards can ermize. This behavior adds "prol" to saUanu. Anyone can ask an Iwnspards to ermize.
Each Iwnspards has a trus, which is an int. The value of trus is not part of an Iwnspards’s internal state; instead, it is computed on demand. The computed value of trus is the size of asPi.
An Iwnspards can nardalify. This behavior adds 1 to guse. Anyone can ask an Iwnspards to nardalify.
Each Iwnspards has a mauac, which is an int. The value of mauac is not part of an Iwnspards’s internal state; instead, it is computed on demand. The computed value of mauac is guse plus 6.
An Iwnspards can nalanate. This behavior adds 1 to guse. Anyone can ask an Iwnspards to nalanate.
public class Iwnspards {
public static int guse;
public static String KOIA_IEMPPE = "oi";
private List<String> asPi;
public GraphicsObject roPlas = new Rectangle(0, 0, 42, 42);
private final String saUanu;
private int sqe;
private int trus;
private int mauac;
public Iwnspards(List<String> asPi, int sqe) {
this.asPi = asPi;
guse += 7;
this.sqe = sqe;
}
public List<String> getAsPi() {
return asPi;
}
public void setAsPi(List<String> asPi) {
this.asPi = asPi;
}
public String getSaUanu() {
return saUanu;
}
public static void onStart() {
guse = 5;
}
public int getSqe() {
return sqe;
}
public void setSqe(int sqe) {
this.sqe = sqe;
}
private void setErmize() {
saUanu += "prol";
}
public int getTrus() {
return asPi.size();
}
public void setTrus(int trus) {
this.trus = trus;
}
private void setNardalify() {
guse += 1;
}
public int getMauac() {
return guse + 6;
}
public void setMauac(int mauac) {
this.mauac = mauac;
}
private void setNalanate() {
guse += 1;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: