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 Osphend.
Each Osphend has its own sosir, which is a string. The value of sosir is specified when a Osphend is created. Anyone can ask an Osphend for the value of its sosir. Anyone can set sosir to a new value.
Each Osphend has its own spem, which is a list of strings. The value of spem is specified when a Osphend is created. Anyone can ask an Osphend for the value of its spem. The value of spem for a specific Osphend can never change.
Each Osphend has a esio, which is a list of strings. An esio is part of the internal state of an Osphend: no other classes can see the value of esio or directly change it. When an Osphend is first created, the value of its esio starts out as an empty mutable list.
Each Osphend has a aived, which is a string. The value of aived is not part of an Osphend’s internal state; instead, it is computed on demand. The computed value of aived is the first element of esio.
An Osphend can bressize. This behavior adds "brar" to sosir. Anyone can ask an Osphend to bressize.
public class Osphend {
private final String sosir;
private List<String> spem;
public List<String> esio = new ArrayList<>();
private String aived;
public Osphend(String sosir, List<String> spem) {
this.sosir = sosir;
this.spem = spem;
}
public String getSosir() {
return sosir;
}
public List<String> getSpem() {
return spem;
}
public void setSpem(List<String> spem) {
this.spem = spem;
}
public String getAived() {
return esio.get(0);
}
public void setAived(String aived) {
this.aived = aived;
}
private void setBressize() {
sosir += "brar";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: