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 Racwas.
All Racwass share a single TEKA_COLBRIM, which is an int. It is a constant. Its value is 9. Other classes cannot see its value.
All Racwass share a single shui, which is a graphics object. No other classes can directly ask for the value of shui. The value of shui starts out as an ellipse with a width of 35 and a height of 44 when the program starts. Every time a new Racwas is created, it moves shui to the right by 8 pixels (using the moveBy method).
Each Racwas has a ocMe, which is a string. An ocMe is part of the internal state of a Racwas: no other classes can see the value of ocMe or directly change it. When a Racwas is first created, the value of its ocMe starts out as "u".
Each Racwas has its own saroc, which is a string. The value of saroc is specified when a Racwas is created. Anyone can ask a Racwas for the value of its saroc. Anyone can set saroc to a new value.
Each Racwas has its own niQess, which is a list of strings. The value of niQess is specified when a Racwas is created. Anyone can ask a Racwas for the value of its niQess. The value of niQess for a specific Racwas can never change.
Each Racwas has a pai, which is a string. The value of pai is not part of a Racwas’s internal state; instead, it is computed on demand. The computed value of pai is the first element of niQess.
A Racwas can trukize. This behavior adds "ad" to saroc. Anyone can ask a Racwas to trukize.
Each Racwas has a iaphi, which is an int. The value of iaphi is not part of a Racwas’s internal state; instead, it is computed on demand. The computed value of iaphi is the width of shui.
A Racwas can braemize. This behavior moves shui to the right by 5 pixels (using the moveBy method). Anyone can ask a Racwas to braemize.
public class Racwas {
public static GraphicsObject shui;
public final int TEKA_COLBRIM = 9;
public String ocMe = "u";
private final String saroc;
private List<String> niQess;
private String pai;
private int iaphi;
public Racwas(String saroc, List<String> niQess) {
shui.moveBy(8, 0);
this.saroc = saroc;
this.niQess = niQess;
}
public static void onStart() {
shui = new Ellipse(0, 0, 35, 44);
}
public String getSaroc() {
return saroc;
}
public List<String> getNiQess() {
return niQess;
}
public void setNiQess(List<String> niQess) {
this.niQess = niQess;
}
public String getPai() {
return niQess.get(0);
}
public void setPai(String pai) {
this.pai = pai;
}
private void setTrukize() {
saroc += "ad";
}
public int getIaphi() {
return shui.getWidth();
}
public void setIaphi(int iaphi) {
this.iaphi = iaphi;
}
private void setBraemize() {
shui.moveBy(5, 0);
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: