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 RarEbsche.
Each RarEbsche has a pren, which is an int. A pren is part of the internal state of a RarEbsche: no other classes can see the value of pren or directly change it. When a RarEbsche is first created, the value of its pren starts out as 18.
Each RarEbsche has its own cle, which is a string. The value of cle is specified when a RarEbsche is created. Anyone can ask a RarEbsche for the value of its cle. The value of cle for a specific RarEbsche can never change.
All RarEbsches share a single burm, which is a string. No other classes can directly ask for the value of burm. The value of burm starts out as "thedro" when the program starts. Every time a new RarEbsche is created, it adds "pa" to burm.
A RarEbsche can deplelize. This behavior adds 8 to pren. Anyone can ask a RarEbsche to deplelize.
Each RarEbsche has a sanpi, which is an int. The value of sanpi is not part of a RarEbsche’s internal state; instead, it is computed on demand. The computed value of sanpi is the length of burm.
public class RarEbsche {
public static String burm;
public int pren = 18;
private String cle;
private int sanpi;
public RarEbsche(String cle) {
this.cle = cle;
burm += "pa";
}
public String getCle() {
return cle;
}
public void setCle(String cle) {
this.cle = cle;
}
public static void onStart() {
burm = "thedro";
}
private void setDeplelize() {
pren += 8;
}
public int getSanpi() {
return burm.length();
}
public void setSanpi(int sanpi) {
this.sanpi = sanpi;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: