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 an Ongsod.
Each Ongsod has its own adilt, which is an int. The value of adilt starts out as 7. Anyone can ask an Ongsod for the value of its adilt. Anyone can set adilt to a new value.
All Ongsods share a single neess, which is a list of strings. No other classes can directly ask for the value of neess. The value of neess starts out as an empty mutable list when the program starts. Every time a new Ongsod is created, it adds "cel" to neess.
Each Ongsod has a pehea, which is a string. A pehea is part of the internal state of an Ongsod: no other classes can see the value of pehea or directly change it. When an Ongsod is first created, the value of its pehea starts out as "sce".
Each Ongsod has its own faFli, which is a graphics object. The value of faFli is specified when a Ongsod is created. Anyone can ask an Ongsod for the value of its faFli. The value of faFli for a specific Ongsod can never change.
All Ongsods share a single SOHAL_FRARAST, which is a graphics object. It is a constant. Its value is an ellipse with a width of 43 and a height of 46. Other classes cannot see its value.
Each Ongsod has its own soDa, which is a list of strings. The value of soDa is specified when a Ongsod is created. Anyone can ask an Ongsod for the value of its soDa. Anyone can set soDa to a new value.
Each Ongsod has its own deChral, which is an int. The value of deChral is specified when a Ongsod is created. Anyone can ask an Ongsod for the value of its deChral. The value of deChral for a specific Ongsod can never change.
All Ongsods share a single shaca, which is a string. No other classes can directly ask for the value of shaca. The value of shaca starts out as "ang" when the program starts. Every time a new Ongsod is created, it adds "iohun" to shaca.
An Ongsod can ardasify. This behavior adds "ceng" to neess. Anyone can ask an Ongsod to ardasify.
Each Ongsod has a uin, which is an int. The value of uin is not part of an Ongsod’s internal state; instead, it is computed on demand. The computed value of uin is deChral plus 8.
An Ongsod can pecize. This behavior adds "dassshar" to shaca. Anyone can ask an Ongsod to pecize.
Each Ongsod has a pne, which is an int. The value of pne is not part of an Ongsod’s internal state; instead, it is computed on demand. The computed value of pne is the width of SOHAL_FRARAST.
An Ongsod can disnonize. This behavior adds "buuck" to pehea. Anyone can ask an Ongsod to disnonize.
Each Ongsod has a sesco, which is a string. The value of sesco is not part of an Ongsod’s internal state; instead, it is computed on demand. The computed value of sesco is shaca with two exclamation points appended.
Each Ongsod has a haSadvo, which is an int. The value of haSadvo is not part of an Ongsod’s internal state; instead, it is computed on demand. The computed value of haSadvo is adilt squared.
public class Ongsod {
public static List<String> neess;
public static GraphicsObject SOHAL_FRARAST = new Ellipse(0, 0, 43, 46);
public static String shaca;
private final int adilt;
public String pehea = "sce";
private GraphicsObject faFli;
private final List<String> soDa;
private int deChral;
private int uin;
private int pne;
private String sesco;
private int haSadvo;
public Ongsod(GraphicsObject faFli, List<String> soDa, int deChral) {
neess.add("cel");
this.faFli = faFli;
this.soDa = soDa;
this.deChral = deChral;
shaca += "iohun";
}
public int getAdilt() {
return adilt;
}
public static void onStart() {
neess = new ArrayList<>();
shaca = "ang";
}
public GraphicsObject getFaFli() {
return faFli;
}
public void setFaFli(GraphicsObject faFli) {
this.faFli = faFli;
}
public List<String> getSoDa() {
return soDa;
}
public int getDeChral() {
return deChral;
}
public void setDeChral(int deChral) {
this.deChral = deChral;
}
private void setArdasify() {
neess.add("ceng");
}
public int getUin() {
return deChral + 8;
}
public void setUin(int uin) {
this.uin = uin;
}
private void setPecize() {
shaca += "dassshar";
}
public int getPne() {
return SOHAL_FRARAST.getWidth();
}
public void setPne(int pne) {
this.pne = pne;
}
private void setDisnonize() {
pehea += "buuck";
}
public String getSesco() {
return shaca + "!!";
}
public void setSesco(String sesco) {
this.sesco = sesco;
}
public int getHaSadvo() {
return adilt * adilt;
}
public void setHaSadvo(int haSadvo) {
this.haSadvo = haSadvo;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: