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 Smuun.
All Smuuns share a single ceen, which is an int. No other classes can directly ask for the value of ceen. The value of ceen starts out as 2 when the program starts. Every time a new Smuun is created, it adds 3 to ceen.
Each Smuun has a alDro, which is a graphics object. An alDro is part of the internal state of a Smuun: no other classes can see the value of alDro or directly change it. When a Smuun is first created, the value of its alDro starts out as a rectangle with a width of 40 and a height of 38.
All Smuuns share a single THACED, which is a list of strings. It is a constant. Its value is ["nur", "fisam", "o"]. Other classes can see its value.
Each Smuun has its own tipid, which is a string. The value of tipid is specified when a Smuun is created. Anyone can ask a Smuun for the value of its tipid. The value of tipid for a specific Smuun can never change.
Each Smuun has its own bleng, which is a graphics object. The value of bleng starts out as an ellipse with a width of 20 and a height of 10. Anyone can ask a Smuun for the value of its bleng. Anyone can set bleng to a new value.
Each Smuun has a eount, which is a string. The value of eount is not part of a Smuun’s internal state; instead, it is computed on demand. The computed value of eount is the first element of THACED.
A Smuun can luolify. This behavior adds 7 to ceen. Anyone can ask a Smuun to luolify.
A Smuun can brinify. This behavior adds 1 to ceen. Anyone can ask a Smuun to brinify.
Each Smuun has a viKni, which is a string. The value of viKni is not part of a Smuun’s internal state; instead, it is computed on demand. The computed value of viKni is tipid with two exclamation points appended.
public class Smuun {
public static int ceen;
private static List<String> THACED = List.of("nur", "fisam", "o");
public GraphicsObject alDro = new Rectangle(0, 0, 40, 38);
private String tipid;
private final GraphicsObject bleng;
private String eount;
private String viKni;
public Smuun(String tipid) {
ceen += 3;
this.tipid = tipid;
}
public static void onStart() {
ceen = 2;
}
public String getTipid() {
return tipid;
}
public void setTipid(String tipid) {
this.tipid = tipid;
}
public GraphicsObject getBleng() {
return bleng;
}
public String getEount() {
return THACED.get(0);
}
public void setEount(String eount) {
this.eount = eount;
}
private void setLuolify() {
ceen += 7;
}
private void setBrinify() {
ceen += 1;
}
public String getViKni() {
return tipid + "!!";
}
public void setViKni(String viKni) {
this.viKni = viKni;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: