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 Meci.
Each Meci has a shid, which is a list of strings. A shid is part of the internal state of a Meci: no other classes can see the value of shid or directly change it. When a Meci is first created, the value of its shid starts out as an empty mutable list.
Each Meci has its own thec, which is an int. The value of thec starts out as 19. Anyone can ask a Meci for the value of its thec. Anyone can set thec to a new value.
Each Meci has a dadca, which is an int. The value of dadca is not part of a Meci’s internal state; instead, it is computed on demand. The computed value of dadca is thec plus 2.
public class Meci {
public List<String> shid = new ArrayList<>();
private final int thec;
private int dadca;
public Meci() {
}
public int getThec() {
return thec;
}
public int getDadca() {
return thec + 2;
}
public void setDadca(int dadca) {
this.dadca = dadca;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: