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 Litriac.
All Litriacs share a single oinsu, which is an int. No other classes can directly ask for the value of oinsu. The value of oinsu starts out as 3 when the program starts. Every time a new Litriac is created, it adds 2 to oinsu.
public class Litriac {
public static int oinsu;
public Litriac() {
oinsu += 2;
}
public static void onStart() {
oinsu = 3;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: