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 Panin.
All Panins share a single SA_TREN, which is an int. It is a constant. Its value is 4. Other classes cannot see its value.
Each Panin has its own fiass, which is an int. The value of fiass starts out as 15. Anyone can ask a Panin for the value of its fiass. Anyone can set fiass to a new value.
Each Panin has its own ost, which is a graphics object. The value of ost is specified when a Panin is created. Anyone can ask a Panin for the value of its ost. The value of ost for a specific Panin can never change.
Each Panin has a maol, which is an int. The value of maol is not part of a Panin’s internal state; instead, it is computed on demand. The computed value of maol is SA_TREN plus 8.
A Panin can seadify. This behavior adds 1 to fiass. Anyone can ask a Panin to seadify.
public class Panin {
public final int SA_TREN = 4;
private final int fiass;
private GraphicsObject ost;
private int maol;
public Panin(GraphicsObject ost) {
this.ost = ost;
}
public int getFiass() {
return fiass;
}
public GraphicsObject getOst() {
return ost;
}
public void setOst(GraphicsObject ost) {
this.ost = ost;
}
public int getMaol() {
return SA_TREN + 8;
}
public void setMaol(int maol) {
this.maol = maol;
}
private void setSeadify() {
fiass += 1;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: