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