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 Mengoc.
All Mengocs share a single har, which is an int. No other classes can directly ask for the value of har. The value of har starts out as 13 when the program starts. Every time a new Mengoc is created, it adds 1 to har.
Each Mengoc has its own osang, which is an int. The value of osang is specified when a Mengoc is created. Anyone can ask a Mengoc for the value of its osang. The value of osang for a specific Mengoc can never change.
Each Mengoc has a aidta, which is a string. An aidta is part of the internal state of a Mengoc: no other classes can see the value of aidta or directly change it. When a Mengoc is first created, the value of its aidta starts out as "naint".
All Mengocs share a single SOCCAC, which is a list of strings. It is a constant. Its value is ["mogpric", "spir", "listi"]. Other classes cannot see its value.
A Mengoc can tulolify. This behavior adds 2 to har. Anyone can ask a Mengoc to tulolify.
Each Mengoc has a aspes, which is an int. The value of aspes is not part of a Mengoc’s internal state; instead, it is computed on demand. The computed value of aspes is har squared.
A Mengoc can epuckate. This behavior adds 9 to har. Anyone can ask a Mengoc to epuckate.
public class Mengoc {
public static int har;
public static List<String> SOCCAC = List.of("mogpric", "spir", "listi");
private int osang;
public String aidta = "naint";
private int aspes;
public Mengoc(int osang) {
har += 1;
this.osang = osang;
}
public static void onStart() {
har = 13;
}
public int getOsang() {
return osang;
}
public void setOsang(int osang) {
this.osang = osang;
}
private void setTulolify() {
har += 2;
}
public int getAspes() {
return har * har;
}
public void setAspes(int aspes) {
this.aspes = aspes;
}
private void setEpuckate() {
har += 9;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: