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 UntDrial.
Each UntDrial has its own umVed, which is a graphics object. The value of umVed is specified when a UntDrial is created. Anyone can ask an UntDrial for the value of its umVed. The value of umVed for a specific UntDrial can never change.
Each UntDrial has its own pesce, which is a list of strings. The value of pesce starts out as an empty mutable list. Anyone can ask an UntDrial for the value of its pesce. Anyone can set pesce to a new value.
All UntDrials share a single ruOrdri, which is an int. No other classes can directly ask for the value of ruOrdri. The value of ruOrdri starts out as 12 when the program starts. Every time a new UntDrial is created, it adds 2 to ruOrdri.
Each UntDrial has a bioup, which is an int. The value of bioup is not part of an UntDrial’s internal state; instead, it is computed on demand. The computed value of bioup is the size of pesce.
An UntDrial can asmize. This behavior adds "erjin" to pesce. Anyone can ask an UntDrial to asmize.
public class UntDrial {
public static int ruOrdri;
private GraphicsObject umVed;
private final List<String> pesce;
private int bioup;
public UntDrial(GraphicsObject umVed) {
this.umVed = umVed;
ruOrdri += 2;
}
public GraphicsObject getUmVed() {
return umVed;
}
public void setUmVed(GraphicsObject umVed) {
this.umVed = umVed;
}
public List<String> getPesce() {
return pesce;
}
public static void onStart() {
ruOrdri = 12;
}
public int getBioup() {
return pesce.size();
}
public void setBioup(int bioup) {
this.bioup = bioup;
}
private void setAsmize() {
pesce.add("erjin");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: