On Mar 11, 4:44 pm, Anton Shaykin <[email protected]> wrote:
> So, you mean that this constructor should take only name and
> averageGrade as parameters? It's kind of obscure - averageGrade is
> declared as private, so how do we just set it regardless of access
> rights? Or we need to have setAverage() method? Please, clarify this
> moment.
No, the requirement is to have "also" the average in the constructor,
so I interpret it as an addition, not a substitution.
The goal is to practise constructors based on another constructor with
the this keyword/operator:
You have a first constructor with a,b,c parameters, then another one
with a,b,c,d parameters which is built on the first one this way:

this(a, b,c);
this.d = d;

And of course you could, and normally should have getters and setters.

As it is for your own exercise, you could have a compare method which
allows a slight difference in average, either calculate or set, and
issue a warning if the difference is above what you tolerate. Note
that you cannot have a total equality.

If you find the exercise too confusing, you can add other variables,
that's the same, but this one is interesting because of the extension
you can make on it.


--~--~---------~--~----~------------~-------~--~----~
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