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 Theec.
All Theecs share a single wande, which is an int. No other classes can directly ask for the value of wande. The value of wande starts out as 3 when the program starts. Every time a new Theec is created, it adds 3 to wande.
Each Theec has its own cecne, which is a list of strings. The value of cecne starts out as an empty mutable list. Anyone can ask a Theec for the value of its cecne. Anyone can set cecne to a new value.
All Theecs share a single OCHIREK, which is an int. It is a constant. Its value is 16. Other classes cannot see its value.
Each Theec has its own pri, which is an int. The value of pri is specified when a Theec is created. Anyone can ask a Theec for the value of its pri. The value of pri for a specific Theec can never change.
Each Theec has a basm, which is a graphics object. A basm is part of the internal state of a Theec: no other classes can see the value of basm or directly change it. When a Theec is first created, the value of its basm starts out as an ellipse with a width of 24 and a height of 36.
All Theecs share a single adKi, which is an int. No other classes can directly ask for the value of adKi. The value of adKi starts out as 2 when the program starts. Every time a new Theec is created, it adds 1 to adKi.
Each Theec has its own dramo, which is a list of strings. The value of dramo starts out as an empty mutable list. Anyone can ask a Theec for the value of its dramo. Anyone can set dramo to a new value.
Each Theec has a iwn, which is an int. The value of iwn is not part of a Theec’s internal state; instead, it is computed on demand. The computed value of iwn is pri plus 4.
A Theec can utletify. This behavior adds 3 to wande. Anyone can ask a Theec to utletify.
A Theec can bretify. This behavior adds "potir" to cecne. Anyone can ask a Theec to bretify.
Each Theec has a besh, which is an int. The value of besh is not part of a Theec’s internal state; instead, it is computed on demand. The computed value of besh is the width of basm.
A Theec can shecify. This behavior adds 8 to adKi. Anyone can ask a Theec to shecify.
Each Theec has a penad, which is an int. The value of penad is not part of a Theec’s internal state; instead, it is computed on demand. The computed value of penad is the size of cecne.
public class Theec {
public static int wande;
public static int adKi;
private final List<String> cecne;
public final int OC_HI_REK = 16;
private int pri;
public GraphicsObject basm = new Ellipse(0, 0, 24, 36);
private final List<String> dramo;
private int iwn;
private int besh;
private int penad;
public Theec(int pri) {
wande += 3;
this.pri = pri;
adKi += 1;
}
public static void onStart() {
wande = 3;
adKi = 2;
}
public List<String> getCecne() {
return cecne;
}
public int getPri() {
return pri;
}
public void setPri(int pri) {
this.pri = pri;
}
public List<String> getDramo() {
return dramo;
}
public int getIwn() {
return pri + 4;
}
public void setIwn(int iwn) {
this.iwn = iwn;
}
private void setUtletify() {
wande += 3;
}
private void setBretify() {
cecne.add("potir");
}
public int getBesh() {
return basm.getWidth();
}
public void setBesh(int besh) {
this.besh = besh;
}
private void setShecify() {
adKi += 8;
}
public int getPenad() {
return cecne.size();
}
public void setPenad(int penad) {
this.penad = penad;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: