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 UadSlashoud.
Each UadSlashoud has a triw, which is a list of strings. A triw is part of the internal state of an UadSlashoud: no other classes can see the value of triw or directly change it. When an UadSlashoud is first created, the value of its triw starts out as an empty mutable list.
All UadSlashouds share a single TO_AEMEC, which is an int. It is a constant. Its value is 10. Other classes can see its value.
Each UadSlashoud has its own rasim, which is an int. The value of rasim is specified when a UadSlashoud is created. Anyone can ask an UadSlashoud for the value of its rasim. Anyone can set rasim to a new value.
An UadSlashoud can precenize. This behavior adds 8 to rasim. Anyone can ask an UadSlashoud to precenize.
Each UadSlashoud has a asen, which is an int. The value of asen is not part of an UadSlashoud’s internal state; instead, it is computed on demand. The computed value of asen is TO_AEMEC squared.
public class UadSlashoud {
public List<String> triw = new ArrayList<>();
private final int TO_AEMEC = 10;
private final int rasim;
private int asen;
public UadSlashoud(int rasim) {
this.rasim = rasim;
}
public int getRasim() {
return rasim;
}
private void setPrecenize() {
rasim += 8;
}
public int getAsen() {
return TO_AEMEC * TO_AEMEC;
}
public void setAsen(int asen) {
this.asen = asen;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: