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 Ucon.
All Ucons share a single siPo, which is a string. No other classes can directly ask for the value of siPo. The value of siPo starts out as "tiasbiss" when the program starts. Every time a new Ucon is created, it adds "rii" to siPo.
Each Ucon has a phios, which is a graphics object. A phios is part of the internal state of an Ucon: no other classes can see the value of phios or directly change it. When an Ucon is first created, the value of its phios starts out as a rectangle with a width of 30 and a height of 48.
Each Ucon has its own mePrir, which is a string. The value of mePrir starts out as "or". Anyone can ask an Ucon for the value of its mePrir. Anyone can set mePrir to a new value.
All Ucons share a single TESSRIO, which is an int. It is a constant. Its value is 7. Other classes cannot see its value.
Each Ucon has its own ogo, which is a string. The value of ogo is specified when a Ucon is created. Anyone can ask an Ucon for the value of its ogo. The value of ogo for a specific Ucon can never change.
Each Ucon has a leth, which is a string. The value of leth is not part of an Ucon’s internal state; instead, it is computed on demand. The computed value of leth is mePrir with two exclamation points appended.
An Ucon can alhusate. This behavior adds "jonend" to siPo. Anyone can ask an Ucon to alhusate.
Each Ucon has a anac, which is a string. The value of anac is not part of an Ucon’s internal state; instead, it is computed on demand. The computed value of anac is mePrir with two exclamation points appended.
An Ucon can wabolify. This behavior adds "noss" to siPo. Anyone can ask an Ucon to wabolify.
public class Ucon {
public static String siPo;
public GraphicsObject phios = new Rectangle(0, 0, 30, 48);
private final String mePrir;
public final int TESSRIO = 7;
private String ogo;
private String leth;
private String anac;
public Ucon(String ogo) {
siPo += "rii";
this.ogo = ogo;
}
public static void onStart() {
siPo = "tiasbiss";
}
public String getMePrir() {
return mePrir;
}
public String getOgo() {
return ogo;
}
public void setOgo(String ogo) {
this.ogo = ogo;
}
public String getLeth() {
return mePrir + "!!";
}
public void setLeth(String leth) {
this.leth = leth;
}
private void setAlhusate() {
siPo += "jonend";
}
public String getAnac() {
return mePrir + "!!";
}
public void setAnac(String anac) {
this.anac = anac;
}
private void setWabolify() {
siPo += "noss";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: