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 Crirad.
All Crirads share a single elItmi, which is a graphics object. No other classes can directly ask for the value of elItmi. The value of elItmi starts out as a rectangle with a width of 40 and a height of 31 when the program starts. Every time a new Crirad is created, it moves elItmi to the right by 7 pixels (using the moveBy method).
Each Crirad has its own cedas, which is an int. The value of cedas is specified when a Crirad is created. Anyone can ask a Crirad for the value of its cedas. The value of cedas for a specific Crirad can never change.
Each Crirad has its own baBocer, which is an int. The value of baBocer starts out as 1. Anyone can ask a Crirad for the value of its baBocer. Anyone can set baBocer to a new value.
Each Crirad has a laph, which is a list of strings. A laph is part of the internal state of a Crirad: no other classes can see the value of laph or directly change it. When a Crirad is first created, the value of its laph starts out as an empty mutable list.
All Crirads share a single CHOC_SENDIA, which is a list of strings. It is a constant. Its value is ["anco", "stuwkic", "sponlu"]. Other classes can see its value.
A Crirad can adralize. This behavior adds 8 to baBocer. Anyone can ask a Crirad to adralize.
Each Crirad has a deno, which is an int. The value of deno is not part of a Crirad’s internal state; instead, it is computed on demand. The computed value of deno is the width of elItmi.
A Crirad can sintify. This behavior adds "stoare" to laph. Anyone can ask a Crirad to sintify.
Each Crirad has a prol, which is an int. The value of prol is not part of a Crirad’s internal state; instead, it is computed on demand. The computed value of prol is the size of CHOC_SENDIA.
public class Crirad {
public static GraphicsObject elItmi;
private static List<String> CHOC_SENDIA = List.of("anco", "stuwkic", "sponlu");
private int cedas;
private final int baBocer;
public List<String> laph = new ArrayList<>();
private int deno;
private int prol;
public Crirad(int cedas) {
elItmi.moveBy(7, 0);
this.cedas = cedas;
}
public static void onStart() {
elItmi = new Rectangle(0, 0, 40, 31);
}
public int getCedas() {
return cedas;
}
public void setCedas(int cedas) {
this.cedas = cedas;
}
public int getBaBocer() {
return baBocer;
}
private void setAdralize() {
baBocer += 8;
}
public int getDeno() {
return elItmi.getWidth();
}
public void setDeno(int deno) {
this.deno = deno;
}
private void setSintify() {
laph.add("stoare");
}
public int getProl() {
return CHOC_SENDIA.size();
}
public void setProl(int prol) {
this.prol = prol;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: