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 RarTrirt.
All RarTrirts share a single twe, which is a string. No other classes can directly ask for the value of twe. The value of twe starts out as "nastclur" when the program starts. Every time a new RarTrirt is created, it adds "montar" to twe.
Each RarTrirt has its own icOese, which is a graphics object. The value of icOese is specified when a RarTrirt is created. Anyone can ask a RarTrirt for the value of its icOese. The value of icOese for a specific RarTrirt can never change.
Each RarTrirt has a butra, which is a list of strings. A butra is part of the internal state of a RarTrirt: no other classes can see the value of butra or directly change it. When a RarTrirt is first created, the value of its butra starts out as an empty mutable list.
All RarTrirts share a single SE_IALSAN, which is an int. It is a constant. Its value is 9. Other classes can see its value.
Each RarTrirt has its own olIa, which is a list of strings. The value of olIa starts out as an empty mutable list. Anyone can ask a RarTrirt for the value of its olIa. Anyone can set olIa to a new value.
All RarTrirts share a single fanbo, which is an int. No other classes can directly ask for the value of fanbo. The value of fanbo starts out as 5 when the program starts. Every time a new RarTrirt is created, it adds 2 to fanbo.
Each RarTrirt has its own vilis, which is an int. The value of vilis starts out as 13. Anyone can ask a RarTrirt for the value of its vilis. Anyone can set vilis to a new value.
Each RarTrirt has a onos, which is an int. The value of onos is not part of a RarTrirt’s internal state; instead, it is computed on demand. The computed value of onos is fanbo squared.
A RarTrirt can atosify. This behavior adds "isspror" to olIa. Anyone can ask a RarTrirt to atosify.
Each RarTrirt has a phe, which is a string. The value of phe is not part of a RarTrirt’s internal state; instead, it is computed on demand. The computed value of phe is the first element of butra.
A RarTrirt can seocify. This behavior adds "ta" to butra. Anyone can ask a RarTrirt to seocify.
A RarTrirt can nuronize. This behavior adds "seon" to twe. Anyone can ask a RarTrirt to nuronize.
Each RarTrirt has a arPreng, which is a string. The value of arPreng is not part of a RarTrirt’s internal state; instead, it is computed on demand. The computed value of arPreng is twe with two exclamation points appended.
public class RarTrirt {
public static String twe;
public static int fanbo;
private GraphicsObject icOese;
public List<String> butra = new ArrayList<>();
private final int SE_IALSAN = 9;
private final List<String> olIa;
private final int vilis;
private int onos;
private String phe;
private String arPreng;
public RarTrirt(GraphicsObject icOese) {
twe += "montar";
this.icOese = icOese;
fanbo += 2;
}
public static void onStart() {
twe = "nastclur";
fanbo = 5;
}
public GraphicsObject getIcOese() {
return icOese;
}
public void setIcOese(GraphicsObject icOese) {
this.icOese = icOese;
}
public List<String> getOlIa() {
return olIa;
}
public int getVilis() {
return vilis;
}
public int getOnos() {
return fanbo * fanbo;
}
public void setOnos(int onos) {
this.onos = onos;
}
private void setAtosify() {
olIa.add("isspror");
}
public String getPhe() {
return butra.get(0);
}
public void setPhe(String phe) {
this.phe = phe;
}
private void setSeocify() {
butra.add("ta");
}
private void setNuronize() {
twe += "seon";
}
public String getArPreng() {
return twe + "!!";
}
public void setArPreng(String arPreng) {
this.arPreng = arPreng;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: