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 Cadfe.
All Cadfes share a single SACPO_WO, which is a string. It is a constant. Its value is "efret". Other classes cannot see its value.
All Cadfes share a single meQusfi, which is a string. No other classes can directly ask for the value of meQusfi. The value of meQusfi starts out as "achwas" when the program starts. Every time a new Cadfe is created, it adds "ninrast" to meQusfi.
Each Cadfe has its own ocial, which is a graphics object. The value of ocial is specified when a Cadfe is created. Anyone can ask a Cadfe for the value of its ocial. The value of ocial for a specific Cadfe can never change.
Each Cadfe has its own biPsal, which is an int. The value of biPsal is specified when a Cadfe is created. Anyone can ask a Cadfe for the value of its biPsal. Anyone can set biPsal to a new value.
Each Cadfe has a pado, which is a string. A pado is part of the internal state of a Cadfe: no other classes can see the value of pado or directly change it. When a Cadfe is first created, the value of its pado starts out as "uim".
Each Cadfe has its own seLesh, which is a string. The value of seLesh is specified when a Cadfe is created. Anyone can ask a Cadfe for the value of its seLesh. Anyone can set seLesh to a new value.
Each Cadfe has a phac, which is a string. The value of phac is not part of a Cadfe’s internal state; instead, it is computed on demand. The computed value of phac is meQusfi with two exclamation points appended.
A Cadfe can tedarate. This behavior adds "es" to seLesh. Anyone can ask a Cadfe to tedarate.
Each Cadfe has a seng, which is an int. The value of seng is not part of a Cadfe’s internal state; instead, it is computed on demand. The computed value of seng is the width of ocial.
A Cadfe can fombenize. This behavior adds "peud" to meQusfi. Anyone can ask a Cadfe to fombenize.
A Cadfe can tetotify. This behavior adds "a" to seLesh. Anyone can ask a Cadfe to tetotify.
public class Cadfe {
public static String SACPO_WO = "efret";
public static String meQusfi;
private GraphicsObject ocial;
private final int biPsal;
public String pado = "uim";
private final String seLesh;
private String phac;
private int seng;
public Cadfe(GraphicsObject ocial, int biPsal, String seLesh) {
meQusfi += "ninrast";
this.ocial = ocial;
this.biPsal = biPsal;
this.seLesh = seLesh;
}
public static void onStart() {
meQusfi = "achwas";
}
public GraphicsObject getOcial() {
return ocial;
}
public void setOcial(GraphicsObject ocial) {
this.ocial = ocial;
}
public int getBiPsal() {
return biPsal;
}
public String getSeLesh() {
return seLesh;
}
public String getPhac() {
return meQusfi + "!!";
}
public void setPhac(String phac) {
this.phac = phac;
}
private void setTedarate() {
seLesh += "es";
}
public int getSeng() {
return ocial.getWidth();
}
public void setSeng(int seng) {
this.seng = seng;
}
private void setFombenize() {
meQusfi += "peud";
}
private void setTetotify() {
seLesh += "a";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: