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 Prast.
Each Prast has its own samiu, which is an int. The value of samiu is specified when a Prast is created. Anyone can ask a Prast for the value of its samiu. The value of samiu for a specific Prast can never change.
All Prasts share a single ceAeste, which is a graphics object. No other classes can directly ask for the value of ceAeste. The value of ceAeste starts out as an ellipse with a width of 47 and a height of 47 when the program starts. Every time a new Prast is created, it moves ceAeste to the right by 6 pixels (using the moveBy method).
Each Prast has its own daarn, which is a graphics object. The value of daarn is specified when a Prast is created. Anyone can ask a Prast for the value of its daarn. Anyone can set daarn to a new value.
Each Prast has a diAae, which is an int. A diAae is part of the internal state of a Prast: no other classes can see the value of diAae or directly change it. When a Prast is first created, the value of its diAae starts out as 13.
All Prasts share a single ARPTE_CIC, which is a graphics object. It is a constant. Its value is an ellipse with a width of 47 and a height of 43. Other classes cannot see its value.
Each Prast has its own raSiwni, which is an int. The value of raSiwni starts out as 5. Anyone can ask a Prast for the value of its raSiwni. Anyone can set raSiwni to a new value.
All Prasts share a single EMTWAN, which is a graphics object. It is a constant. Its value is an ellipse with a width of 45 and a height of 49. Other classes can see its value.
A Prast can iulify. This behavior adds 8 to diAae. Anyone can ask a Prast to iulify.
Each Prast has a iol, which is an int. The value of iol is not part of a Prast’s internal state; instead, it is computed on demand. The computed value of iol is the width of ceAeste.
A Prast can aiwate. This behavior moves ceAeste to the right by 6 pixels (using the moveBy method). Anyone can ask a Prast to aiwate.
Each Prast has a ris, which is an int. The value of ris is not part of a Prast’s internal state; instead, it is computed on demand. The computed value of ris is the width of ceAeste.
Each Prast has a piont, which is an int. The value of piont is not part of a Prast’s internal state; instead, it is computed on demand. The computed value of piont is raSiwni squared.
A Prast can spiapify. This behavior adds 4 to raSiwni. Anyone can ask a Prast to spiapify.
public class Prast {
public static GraphicsObject ceAeste;
public static GraphicsObject ARPTE_CIC = new Ellipse(0, 0, 47, 43);
private static GraphicsObject EMTWAN = new Ellipse(0, 0, 45, 49);
private int samiu;
private final GraphicsObject daarn;
public int diAae = 13;
private final int raSiwni;
private int iol;
private int ris;
private int piont;
public Prast(int samiu, GraphicsObject daarn) {
this.samiu = samiu;
ceAeste.moveBy(6, 0);
this.daarn = daarn;
}
public int getSamiu() {
return samiu;
}
public void setSamiu(int samiu) {
this.samiu = samiu;
}
public static void onStart() {
ceAeste = new Ellipse(0, 0, 47, 47);
}
public GraphicsObject getDaarn() {
return daarn;
}
public int getRaSiwni() {
return raSiwni;
}
private void setIulify() {
diAae += 8;
}
public int getIol() {
return ceAeste.getWidth();
}
public void setIol(int iol) {
this.iol = iol;
}
private void setAiwate() {
ceAeste.moveBy(6, 0);
}
public int getRis() {
return ceAeste.getWidth();
}
public void setRis(int ris) {
this.ris = ris;
}
public int getPiont() {
return raSiwni * raSiwni;
}
public void setPiont(int piont) {
this.piont = piont;
}
private void setSpiapify() {
raSiwni += 4;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: