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 JirCoor.
Each JirCoor has its own malel, which is a graphics object. The value of malel is specified when a JirCoor is created. Anyone can ask a JirCoor for the value of its malel. The value of malel for a specific JirCoor can never change.
All JirCoors share a single POTH_ER, which is a graphics object. It is a constant. Its value is an ellipse with a width of 10 and a height of 17. Other classes can see its value.
All JirCoors share a single toDente, which is a string. No other classes can directly ask for the value of toDente. The value of toDente starts out as "evar" when the program starts. Every time a new JirCoor is created, it adds "pid" to toDente.
Each JirCoor has a malae, which is an int. A malae is part of the internal state of a JirCoor: no other classes can see the value of malae or directly change it. When a JirCoor is first created, the value of its malae starts out as 4.
Each JirCoor has its own heMehas, which is a graphics object. The value of heMehas starts out as an ellipse with a width of 16 and a height of 23. Anyone can ask a JirCoor for the value of its heMehas. Anyone can set heMehas to a new value.
Each JirCoor has its own odis, which is a graphics object. The value of odis is specified when a JirCoor is created. Anyone can ask a JirCoor for the value of its odis. Anyone can set odis to a new value.
A JirCoor can rexsilify. This behavior adds 2 to malae. Anyone can ask a JirCoor to rexsilify.
Each JirCoor has a isDou, which is an int. The value of isDou is not part of a JirCoor’s internal state; instead, it is computed on demand. The computed value of isDou is the width of malel.
A JirCoor can popanify. This behavior adds "papsu" to toDente. Anyone can ask a JirCoor to popanify.
Each JirCoor has a nost, which is an int. The value of nost is not part of a JirCoor’s internal state; instead, it is computed on demand. The computed value of nost is the width of odis.
Each JirCoor has a anPa, which is an int. The value of anPa is not part of a JirCoor’s internal state; instead, it is computed on demand. The computed value of anPa is the x position of POTH_ER.
public class JirCoor {
private static GraphicsObject POTH_ER = new Ellipse(0, 0, 10, 17);
public static String toDente;
private GraphicsObject malel;
public int malae = 4;
private final GraphicsObject heMehas;
private final GraphicsObject odis;
private int isDou;
private int nost;
private int anPa;
public JirCoor(GraphicsObject malel, GraphicsObject odis) {
this.malel = malel;
toDente += "pid";
this.odis = odis;
}
public GraphicsObject getMalel() {
return malel;
}
public void setMalel(GraphicsObject malel) {
this.malel = malel;
}
public static void onStart() {
toDente = "evar";
}
public GraphicsObject getHeMehas() {
return heMehas;
}
public GraphicsObject getOdis() {
return odis;
}
private void setRexsilify() {
malae += 2;
}
public int getIsDou() {
return malel.getWidth();
}
public void setIsDou(int isDou) {
this.isDou = isDou;
}
private void setPopanify() {
toDente += "papsu";
}
public int getNost() {
return odis.getWidth();
}
public void setNost(int nost) {
this.nost = nost;
}
public int getAnPa() {
return POTH_ER.getX();
}
public void setAnPa(int anPa) {
this.anPa = anPa;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: