On Feb 27, 11:36 am, [email protected] wrote:
> Thank you.
>
> Now I find this constructor redundant.
> // Redundant? I cannot pass the average argument here.
> StudentRecord annaRecord=new StudentRecord("Anna",90,91,92,0);
> double avg=annaRecord.getAverage();
>
> // This would accomplish the same. Use the other constructor.
> StudentRecord annaRecord=new StudentRecord("Anna",90,91,92);
> double avg=annaRecord.getAverage();
Yes, you are right, it is redundant. It is just an exercise to show
you that you may always create another constructor with additional
parameters.
If you find it more useful, you may create say birthDate, or
birthPlace, or what you like. And have that new constructor allows you
to construct a new StudentRecord instance with this parameter.
Or you may compare the calculation of the average of grades based upon
individual grades to the one you pass, and change (with appropriate
getters and setters) the average parameter you enter.
There is no limit here to your imagination.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to