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 Pefas.
Each Pefas has its own sas, which is an int. The value of sas starts out as 16. Anyone can ask a Pefas for the value of its sas. Anyone can set sas to a new value.
Each Pefas has a phell, which is a graphics object. A phell is part of the internal state of a Pefas: no other classes can see the value of phell or directly change it. When a Pefas is first created, the value of its phell starts out as a rectangle with a width of 34 and a height of 31.
All Pefass share a single REMAR_UEN, which is a graphics object. It is a constant. Its value is a rectangle with a width of 13 and a height of 48. Other classes can see its value.
A Pefas can poirmize. This behavior adds 1 to sas. Anyone can ask a Pefas to poirmize.
Each Pefas has a dresh, which is an int. The value of dresh is not part of a Pefas’s internal state; instead, it is computed on demand. The computed value of dresh is the x position of phell.
public class Pefas {
private static GraphicsObject REMAR_UEN = new Rectangle(0, 0, 13, 48);
private final int sas;
public GraphicsObject phell = new Rectangle(0, 0, 34, 31);
private int dresh;
public Pefas() {
}
public int getSas() {
return sas;
}
private void setPoirmize() {
sas += 1;
}
public int getDresh() {
return phell.getX();
}
public void setDresh(int dresh) {
this.dresh = dresh;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: