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 NupGlacer.
Each NupGlacer has its own cuSwint, which is an int. The value of cuSwint is specified when a NupGlacer is created. Anyone can ask a NupGlacer for the value of its cuSwint. The value of cuSwint for a specific NupGlacer can never change.
All NupGlacers share a single BRIP_PIO, which is an int. It is a constant. Its value is 6. Other classes cannot see its value.
All NupGlacers share a single basi, which is an int. No other classes can directly ask for the value of basi. The value of basi starts out as 15 when the program starts. Every time a new NupGlacer is created, it adds 5 to basi.
Each NupGlacer has a miIsse, which is an int. A miIsse is part of the internal state of a NupGlacer: no other classes can see the value of miIsse or directly change it. When a NupGlacer is first created, the value of its miIsse starts out as 8.
Each NupGlacer has its own eesh, which is a string. The value of eesh is specified when a NupGlacer is created. Anyone can ask a NupGlacer for the value of its eesh. Anyone can set eesh to a new value.
All NupGlacers share a single iras, which is an int. No other classes can directly ask for the value of iras. The value of iras starts out as 1 when the program starts. Every time a new NupGlacer is created, it adds 5 to iras.
Each NupGlacer has a ruSnunt, which is an int. The value of ruSnunt is not part of a NupGlacer’s internal state; instead, it is computed on demand. The computed value of ruSnunt is BRIP_PIO squared.
A NupGlacer can chiarify. This behavior adds "de" to eesh. Anyone can ask a NupGlacer to chiarify.
A NupGlacer can ancifate. This behavior adds 6 to miIsse. Anyone can ask a NupGlacer to ancifate.
Each NupGlacer has a osscu, which is an int. The value of osscu is not part of a NupGlacer’s internal state; instead, it is computed on demand. The computed value of osscu is cuSwint plus 6.
Each NupGlacer has a thunt, which is an int. The value of thunt is not part of a NupGlacer’s internal state; instead, it is computed on demand. The computed value of thunt is the length of eesh.
public class NupGlacer {
public static int basi;
public static int iras;
private int cuSwint;
public final int BRIP_PIO = 6;
public int miIsse = 8;
private final String eesh;
private int ruSnunt;
private int osscu;
private int thunt;
public NupGlacer(int cuSwint, String eesh) {
this.cuSwint = cuSwint;
basi += 5;
this.eesh = eesh;
iras += 5;
}
public int getCuSwint() {
return cuSwint;
}
public void setCuSwint(int cuSwint) {
this.cuSwint = cuSwint;
}
public static void onStart() {
basi = 15;
iras = 1;
}
public String getEesh() {
return eesh;
}
public int getRuSnunt() {
return BRIP_PIO * BRIP_PIO;
}
public void setRuSnunt(int ruSnunt) {
this.ruSnunt = ruSnunt;
}
private void setChiarify() {
eesh += "de";
}
private void setAncifate() {
miIsse += 6;
}
public int getOsscu() {
return cuSwint + 6;
}
public void setOsscu(int osscu) {
this.osscu = osscu;
}
public int getThunt() {
return eesh.length();
}
public void setThunt(int thunt) {
this.thunt = thunt;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: