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 Mosm.
Each Mosm has its own waWhon, which is a string. The value of waWhon is specified when a Mosm is created. Anyone can ask a Mosm for the value of its waWhon. The value of waWhon for a specific Mosm can never change.
All Mosms share a single anmi, which is a graphics object. No other classes can directly ask for the value of anmi. The value of anmi starts out as an ellipse with a width of 28 and a height of 35 when the program starts. Every time a new Mosm is created, it moves anmi to the right by 8 pixels (using the moveBy method).
Each Mosm has its own clome, which is a list of strings. The value of clome is specified when a Mosm is created. Anyone can ask a Mosm for the value of its clome. Anyone can set clome to a new value.
Each Mosm has a frana, which is a list of strings. A frana is part of the internal state of a Mosm: no other classes can see the value of frana or directly change it. When a Mosm is first created, the value of its frana starts out as an empty mutable list.
All Mosms share a single BLASSAL, which is a graphics object. It is a constant. Its value is a rectangle with a width of 43 and a height of 46. Other classes cannot see its value.
A Mosm can dresize. This behavior adds "onie" to clome. Anyone can ask a Mosm to dresize.
Each Mosm has a kehe, which is an int. The value of kehe is not part of a Mosm’s internal state; instead, it is computed on demand. The computed value of kehe is the size of clome.
Each Mosm has a iss, which is an int. The value of iss is not part of a Mosm’s internal state; instead, it is computed on demand. The computed value of iss is the width of BLASSAL.
A Mosm can sussenify. This behavior adds "costrut" to frana. Anyone can ask a Mosm to sussenify.
public class Mosm {
public static GraphicsObject anmi;
public static GraphicsObject BLASSAL = new Rectangle(0, 0, 43, 46);
private String waWhon;
private final List<String> clome;
public List<String> frana = new ArrayList<>();
private int kehe;
private int iss;
public Mosm(String waWhon, List<String> clome) {
this.waWhon = waWhon;
anmi.moveBy(8, 0);
this.clome = clome;
}
public String getWaWhon() {
return waWhon;
}
public void setWaWhon(String waWhon) {
this.waWhon = waWhon;
}
public static void onStart() {
anmi = new Ellipse(0, 0, 28, 35);
}
public List<String> getClome() {
return clome;
}
private void setDresize() {
clome.add("onie");
}
public int getKehe() {
return clome.size();
}
public void setKehe(int kehe) {
this.kehe = kehe;
}
public int getIss() {
return BLASSAL.getWidth();
}
public void setIss(int iss) {
this.iss = iss;
}
private void setSussenify() {
frana.add("costrut");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: