So i got Graph.java file and there is a method (there is more stuff in there):
public Graph(double y, int gr, String title, double vidurkis, double trend) {
grooms = gr;
}
And this Graph method is no more mentioned in this Graph.java file. Now after grooms variable becomes = gr = 30. And 30 never mentioned in this Graph.java. So i imagine this method is being called from other file, right?
Now there is BrideInSwing.java file and there is have also Graph method used:
if (which == 1){
graphic = new Graph((Math.floor(((d_bride+d_groom) * 3 + divorce) * 10)) / 10, grooms, "Number of grooms: " + grooms + "; bride distribution: " + d_bride + "; grooms distribution: " + d_groom, pr_vidurkis, trend);
} else {
graphic = new Graph((Math.floor((d_bride + d_groom) * 3 * 10)) / 10, grooms, "Number of grooms: " + grooms + "; bride distribution: " + d_bride + "; grooms distribution: " + d_groom, pr_vidurkis, trend);
}
So from what i understand this calls Graph method with parameters corresponding in Graph.java file? If so, then why there is more parameters given here than in Graph.java file where it is only 5: y, gr, title, vidurkis, trend.
Or am I completely missing something here? Thanks.
public methods, by definition, are intended to be called from the oustide of the class (they can be called from the inside also, but if that’s the only goal, the method should be private).
This method, however, is not a method, but a constructor.
And it’s invoked with 5 arguments:
Math.floor(((d_bride+d_groom)*3+divorce)*10))/10,grooms,"Number of grooms: "+grooms+"; bride distribution: "+d_bride+"; grooms distribution: "+d_groom,pr_vidurkis,trendWhat’s the most troubling from your code is that the constructor takes 5 arguments, but does nothing with 4 of them. EIther the arguments should be used, or they should be removed.