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 Uring.
Each Uring has its own praid, which is a list of strings. The value of praid is specified when a Uring is created. Anyone can ask an Uring for the value of its praid. Anyone can set praid to a new value.
All Urings share a single haein, which is an int. No other classes can directly ask for the value of haein. The value of haein starts out as 7 when the program starts. Every time a new Uring is created, it adds 1 to haein.
Each Uring has a sosca, which is an int. A sosca is part of the internal state of an Uring: no other classes can see the value of sosca or directly change it. When an Uring is first created, the value of its sosca starts out as 7.
All Urings share a single SLELDMI, which is a list of strings. It is a constant. Its value is ["sesm", "sas"]. Other classes cannot see its value.
Each Uring has its own essiu, which is a list of strings. The value of essiu is specified when a Uring is created. Anyone can ask an Uring for the value of its essiu. The value of essiu for a specific Uring can never change.
An Uring can plasate. This behavior adds 9 to haein. Anyone can ask an Uring to plasate.
Each Uring has a osan, which is an int. The value of osan is not part of an Uring’s internal state; instead, it is computed on demand. The computed value of osan is the size of essiu.
Each Uring has a teso, which is an int. The value of teso is not part of an Uring’s internal state; instead, it is computed on demand. The computed value of teso is sosca squared.
An Uring can ressate. This behavior adds "osnaud" to praid. Anyone can ask an Uring to ressate.
public class Uring {
public static int haein;
public static List<String> SLELDMI = List.of("sesm", "sas");
private final List<String> praid;
public int sosca = 7;
private List<String> essiu;
private int osan;
private int teso;
public Uring(List<String> praid, List<String> essiu) {
this.praid = praid;
haein += 1;
this.essiu = essiu;
}
public List<String> getPraid() {
return praid;
}
public static void onStart() {
haein = 7;
}
public List<String> getEssiu() {
return essiu;
}
public void setEssiu(List<String> essiu) {
this.essiu = essiu;
}
private void setPlasate() {
haein += 9;
}
public int getOsan() {
return essiu.size();
}
public void setOsan(int osan) {
this.osan = osan;
}
public int getTeso() {
return sosca * sosca;
}
public void setTeso(int teso) {
this.teso = teso;
}
private void setRessate() {
praid.add("osnaud");
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: