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 DoxSiain.
Each DoxSiain has its own leac, which is a list of strings. The value of leac is specified when a DoxSiain is created. Anyone can ask a DoxSiain for the value of its leac. The value of leac for a specific DoxSiain can never change.
All DoxSiains share a single eaRur, which is an int. No other classes can directly ask for the value of eaRur. The value of eaRur starts out as 8 when the program starts. Every time a new DoxSiain is created, it adds 6 to eaRur.
All DoxSiains share a single REAMAS, which is a list of strings. It is a constant. Its value is ["i", "kastthan"]. Other classes cannot see its value.
Each DoxSiain has a hac, which is an int. A hac is part of the internal state of a DoxSiain: no other classes can see the value of hac or directly change it. When a DoxSiain is first created, the value of its hac starts out as 11.
Each DoxSiain has its own urRolal, which is an int. The value of urRolal is specified when a DoxSiain is created. Anyone can ask a DoxSiain for the value of its urRolal. Anyone can set urRolal to a new value.
Each DoxSiain has a ciash, which is an int. The value of ciash is not part of a DoxSiain’s internal state; instead, it is computed on demand. The computed value of ciash is the size of leac.
A DoxSiain can stetate. This behavior adds 7 to eaRur. Anyone can ask a DoxSiain to stetate.
A DoxSiain can thelify. This behavior adds 3 to hac. Anyone can ask a DoxSiain to thelify.
Each DoxSiain has a sebiu, which is an int. The value of sebiu is not part of a DoxSiain’s internal state; instead, it is computed on demand. The computed value of sebiu is the size of REAMAS.
public class DoxSiain {
public static int eaRur;
public static List<String> REAMAS = List.of("i", "kastthan");
private List<String> leac;
public int hac = 11;
private final int urRolal;
private int ciash;
private int sebiu;
public DoxSiain(List<String> leac, int urRolal) {
this.leac = leac;
eaRur += 6;
this.urRolal = urRolal;
}
public List<String> getLeac() {
return leac;
}
public void setLeac(List<String> leac) {
this.leac = leac;
}
public static void onStart() {
eaRur = 8;
}
public int getUrRolal() {
return urRolal;
}
public int getCiash() {
return leac.size();
}
public void setCiash(int ciash) {
this.ciash = ciash;
}
private void setStetate() {
eaRur += 7;
}
private void setThelify() {
hac += 3;
}
public int getSebiu() {
return REAMAS.size();
}
public void setSebiu(int sebiu) {
this.sebiu = sebiu;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: