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 Conprust.
Each Conprust has a ulGraus, which is an int. An ulGraus is part of the internal state of a Conprust: no other classes can see the value of ulGraus or directly change it. When a Conprust is first created, the value of its ulGraus starts out as 4.
Each Conprust has its own inDeung, which is an int. The value of inDeung starts out as 8. Anyone can ask a Conprust for the value of its inDeung. Anyone can set inDeung to a new value.
All Conprusts share a single REDU_PHUD, which is a list of strings. It is a constant. Its value is ["prengton", "lec", "fros"]. Other classes can see its value.
Each Conprust has its own heBahu, which is a graphics object. The value of heBahu is specified when a Conprust is created. Anyone can ask a Conprust for the value of its heBahu. The value of heBahu for a specific Conprust can never change.
All Conprusts share a single rords, which is a list of strings. No other classes can directly ask for the value of rords. The value of rords starts out as an empty mutable list when the program starts. Every time a new Conprust is created, it adds "a" to rords.
Each Conprust has a iasad, which is an int. The value of iasad is not part of a Conprust’s internal state; instead, it is computed on demand. The computed value of iasad is inDeung squared.
A Conprust can insetize. This behavior adds 9 to ulGraus. Anyone can ask a Conprust to insetize.
Each Conprust has a mapot, which is a string. The value of mapot is not part of a Conprust’s internal state; instead, it is computed on demand. The computed value of mapot is the first element of rords.
A Conprust can dighate. This behavior adds 4 to ulGraus. Anyone can ask a Conprust to dighate.
public class Conprust {
private static List<String> REDU_PHUD = List.of("prengton", "lec", "fros");
public static List<String> rords;
public int ulGraus = 4;
private final int inDeung;
private GraphicsObject heBahu;
private int iasad;
private String mapot;
public Conprust(GraphicsObject heBahu) {
this.heBahu = heBahu;
rords.add("a");
}
public int getInDeung() {
return inDeung;
}
public GraphicsObject getHeBahu() {
return heBahu;
}
public void setHeBahu(GraphicsObject heBahu) {
this.heBahu = heBahu;
}
public static void onStart() {
rords = new ArrayList<>();
}
public int getIasad() {
return inDeung * inDeung;
}
public void setIasad(int iasad) {
this.iasad = iasad;
}
private void setInsetize() {
ulGraus += 9;
}
public String getMapot() {
return rords.get(0);
}
public void setMapot(String mapot) {
this.mapot = mapot;
}
private void setDighate() {
ulGraus += 4;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: