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 Spelo.
Each Spelo has a riap, which is a string. A riap is part of the internal state of a Spelo: no other classes can see the value of riap or directly change it. When a Spelo is first created, the value of its riap starts out as "siphel".
All Spelos share a single ost, which is an int. No other classes can directly ask for the value of ost. The value of ost starts out as 12 when the program starts. Every time a new Spelo is created, it adds 3 to ost.
Each Spelo has its own loRa, which is a list of strings. The value of loRa starts out as an empty mutable list. Anyone can ask a Spelo for the value of its loRa. Anyone can set loRa to a new value.
Each Spelo has a binpi, which is an int. The value of binpi is not part of a Spelo’s internal state; instead, it is computed on demand. The computed value of binpi is ost squared.
A Spelo can brelate. This behavior adds 4 to ost. Anyone can ask a Spelo to brelate.
public class Spelo {
public static int ost;
public String riap = "siphel";
private final List<String> loRa;
private int binpi;
public Spelo() {
ost += 3;
}
public static void onStart() {
ost = 12;
}
public List<String> getLoRa() {
return loRa;
}
public int getBinpi() {
return ost * ost;
}
public void setBinpi(int binpi) {
this.binpi = binpi;
}
private void setBrelate() {
ost += 4;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: