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 Sapal.
All Sapals share a single fiSca, which is an int. No other classes can directly ask for the value of fiSca. The value of fiSca starts out as 19 when the program starts. Every time a new Sapal is created, it adds 3 to fiSca.
Each Sapal has its own noe, which is a list of strings. The value of noe is specified when a Sapal is created. Anyone can ask a Sapal for the value of its noe. The value of noe for a specific Sapal can never change.
Each Sapal has a ihEc, which is an int. The value of ihEc is not part of a Sapal’s internal state; instead, it is computed on demand. The computed value of ihEc is fiSca squared.
public class Sapal {
public static int fiSca;
private List<String> noe;
private int ihEc;
public Sapal(List<String> noe) {
fiSca += 3;
this.noe = noe;
}
public static void onStart() {
fiSca = 19;
}
public List<String> getNoe() {
return noe;
}
public void setNoe(List<String> noe) {
this.noe = noe;
}
public int getIhEc() {
return fiSca * fiSca;
}
public void setIhEc(int ihEc) {
this.ihEc = ihEc;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: