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 Huntflis.
Each Huntflis has a oogri, which is an int. An oogri is part of the internal state of a Huntflis: no other classes can see the value of oogri or directly change it. When a Huntflis is first created, the value of its oogri starts out as 18.
All Huntfliss share a single PHUID_TRICBLA, which is a list of strings. It is a constant. Its value is ["niasbud", "neirs"]. Other classes can see its value.
Each Huntflis has its own eper, which is a string. The value of eper starts out as "roarlil". Anyone can ask a Huntflis for the value of its eper. Anyone can set eper to a new value.
Each Huntflis has its own knon, which is a string. The value of knon is specified when a Huntflis is created. Anyone can ask a Huntflis for the value of its knon. The value of knon for a specific Huntflis can never change.
All Huntfliss share a single huQilda, which is a list of strings. No other classes can directly ask for the value of huQilda. The value of huQilda starts out as an empty mutable list when the program starts. Every time a new Huntflis is created, it adds "me" to huQilda.
A Huntflis can ewelize. This behavior adds "sostou" to eper. Anyone can ask a Huntflis to ewelize.
Each Huntflis has a reHeu, which is a string. The value of reHeu is not part of a Huntflis’s internal state; instead, it is computed on demand. The computed value of reHeu is eper with two exclamation points appended.
A Huntflis can bloutize. This behavior adds "ni" to eper. Anyone can ask a Huntflis to bloutize.
Each Huntflis has a cacal, which is an int. The value of cacal is not part of a Huntflis’s internal state; instead, it is computed on demand. The computed value of cacal is oogri plus 7.
public class Huntflis {
private static List<String> PHUID_TRICBLA = List.of("niasbud", "neirs");
public static List<String> huQilda;
public int oogri = 18;
private final String eper;
private String knon;
private String reHeu;
private int cacal;
public Huntflis(String knon) {
this.knon = knon;
huQilda.add("me");
}
public String getEper() {
return eper;
}
public String getKnon() {
return knon;
}
public void setKnon(String knon) {
this.knon = knon;
}
public static void onStart() {
huQilda = new ArrayList<>();
}
private void setEwelize() {
eper += "sostou";
}
public String getReHeu() {
return eper + "!!";
}
public void setReHeu(String reHeu) {
this.reHeu = reHeu;
}
private void setBloutize() {
eper += "ni";
}
public int getCacal() {
return oogri + 7;
}
public void setCacal(int cacal) {
this.cacal = cacal;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: