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 Comi.
Each Comi has its own ics, which is a string. The value of ics is specified when a Comi is created. Anyone can ask a Comi for the value of its ics. The value of ics for a specific Comi can never change.
Each Comi has its own cras, which is an int. The value of cras starts out as 4. Anyone can ask a Comi for the value of its cras. Anyone can set cras to a new value.
A Comi can dusnelize. This behavior adds 5 to cras. Anyone can ask a Comi to dusnelize.
public class Comi {
private String ics;
private final int cras;
public Comi(String ics) {
this.ics = ics;
}
public String getIcs() {
return ics;
}
public void setIcs(String ics) {
this.ics = ics;
}
public int getCras() {
return cras;
}
private void setDusnelize() {
cras += 5;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: