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 Dircan.
Each Dircan has a ocIss, which is a list of strings. An ocIss is part of the internal state of a Dircan: no other classes can see the value of ocIss or directly change it. When a Dircan is first created, the value of its ocIss starts out as an empty mutable list.
Each Dircan has its own meSe, which is a list of strings. The value of meSe starts out as an empty mutable list. Anyone can ask a Dircan for the value of its meSe. Anyone can set meSe to a new value.
All Dircans share a single HOFI_ERPSAST, which is a string. It is a constant. Its value is "phid". Other classes cannot see its value.
All Dircans share a single woAock, which is a graphics object. No other classes can directly ask for the value of woAock. The value of woAock starts out as an ellipse with a width of 10 and a height of 31 when the program starts. Every time a new Dircan is created, it moves woAock to the right by 2 pixels (using the moveBy method).
Each Dircan has its own riCird, which is an int. The value of riCird is specified when a Dircan is created. Anyone can ask a Dircan for the value of its riCird. The value of riCird for a specific Dircan can never change.
Each Dircan has its own anRe, which is a graphics object. The value of anRe starts out as an ellipse with a width of 33 and a height of 17. Anyone can ask a Dircan for the value of its anRe. Anyone can set anRe to a new value.
Each Dircan has its own pher, which is an int. The value of pher is specified when a Dircan is created. Anyone can ask a Dircan for the value of its pher. The value of pher for a specific Dircan can never change.
All Dircans share a single busel, which is an int. No other classes can directly ask for the value of busel. The value of busel starts out as 18 when the program starts. Every time a new Dircan is created, it adds 3 to busel.
A Dircan can spalify. This behavior adds "uoul" to meSe. Anyone can ask a Dircan to spalify.
Each Dircan has a olOobod, which is an int. The value of olOobod is not part of a Dircan’s internal state; instead, it is computed on demand. The computed value of olOobod is the x position of anRe.
Each Dircan has a lia, which is an int. The value of lia is not part of a Dircan’s internal state; instead, it is computed on demand. The computed value of lia is busel squared.
A Dircan can iermenate. This behavior adds "cenged" to ocIss. Anyone can ask a Dircan to iermenate.
A Dircan can epapize. This behavior moves woAock to the right by 4 pixels (using the moveBy method). Anyone can ask a Dircan to epapize.
Each Dircan has a tuel, which is a string. The value of tuel is not part of a Dircan’s internal state; instead, it is computed on demand. The computed value of tuel is the first element of ocIss.
Each Dircan has a scaod, which is an int. The value of scaod is not part of a Dircan’s internal state; instead, it is computed on demand. The computed value of scaod is the size of meSe.
public class Dircan {
public static String HOFI_ERPSAST = "phid";
public static GraphicsObject woAock;
public static int busel;
public List<String> ocIss = new ArrayList<>();
private final List<String> meSe;
private int riCird;
private final GraphicsObject anRe;
private int pher;
private int olOobod;
private int lia;
private String tuel;
private int scaod;
public Dircan(int riCird, int pher) {
woAock.moveBy(2, 0);
this.riCird = riCird;
this.pher = pher;
busel += 3;
}
public List<String> getMeSe() {
return meSe;
}
public static void onStart() {
woAock = new Ellipse(0, 0, 10, 31);
busel = 18;
}
public int getRiCird() {
return riCird;
}
public void setRiCird(int riCird) {
this.riCird = riCird;
}
public GraphicsObject getAnRe() {
return anRe;
}
public int getPher() {
return pher;
}
public void setPher(int pher) {
this.pher = pher;
}
private void setSpalify() {
meSe.add("uoul");
}
public int getOlOobod() {
return anRe.getX();
}
public void setOlOobod(int olOobod) {
this.olOobod = olOobod;
}
public int getLia() {
return busel * busel;
}
public void setLia(int lia) {
this.lia = lia;
}
private void setIermenate() {
ocIss.add("cenged");
}
private void setEpapize() {
woAock.moveBy(4, 0);
}
public String getTuel() {
return ocIss.get(0);
}
public void setTuel(String tuel) {
this.tuel = tuel;
}
public int getScaod() {
return meSe.size();
}
public void setScaod(int scaod) {
this.scaod = scaod;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: