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 Mirnos.
Each Mirnos has its own lashi, which is an int. The value of lashi is specified when a Mirnos is created. Anyone can ask a Mirnos for the value of its lashi. The value of lashi for a specific Mirnos can never change.
All Mirnoss share a single TRIEHI, which is an int. It is a constant. Its value is 5. Other classes cannot see its value.
Each Mirnos has a peIrva, which is a string. A peIrva is part of the internal state of a Mirnos: no other classes can see the value of peIrva or directly change it. When a Mirnos is first created, the value of its peIrva starts out as "pliden".
Each Mirnos has a puSi, which is an int. The value of puSi is not part of a Mirnos’s internal state; instead, it is computed on demand. The computed value of puSi is TRIEHI squared.
A Mirnos can prassize. This behavior adds "bleang" to peIrva. Anyone can ask a Mirnos to prassize.
public class Mirnos {
private int lashi;
public final int TRIEHI = 5;
public String peIrva = "pliden";
private int puSi;
public Mirnos(int lashi) {
this.lashi = lashi;
}
public int getLashi() {
return lashi;
}
public void setLashi(int lashi) {
this.lashi = lashi;
}
public int getPuSi() {
return TRIEHI * TRIEHI;
}
public void setPuSi(int puSi) {
this.puSi = puSi;
}
private void setPrassize() {
peIrva += "bleang";
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: