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 Sicuas.
Each Sicuas has its own baEn, which is a list of strings. The value of baEn is specified when a Sicuas is created. Anyone can ask a Sicuas for the value of its baEn. The value of baEn for a specific Sicuas can never change.
All Sicuass share a single oss, which is a list of strings. No other classes can directly ask for the value of oss. The value of oss starts out as an empty mutable list when the program starts. Every time a new Sicuas is created, it adds "co" to oss.
Each Sicuas has a swio, which is an int. The value of swio is not part of a Sicuas’s internal state; instead, it is computed on demand. The computed value of swio is the size of baEn.
public class Sicuas {
public static List<String> oss;
private List<String> baEn;
private int swio;
public Sicuas(List<String> baEn) {
this.baEn = baEn;
oss.add("co");
}
public List<String> getBaEn() {
return baEn;
}
public void setBaEn(List<String> baEn) {
this.baEn = baEn;
}
public static void onStart() {
oss = new ArrayList<>();
}
public int getSwio() {
return baEn.size();
}
public void setSwio(int swio) {
this.swio = swio;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: