The constructor is:
public DinnerParty(int numberOfPeople, bool healthyOption, bool fancyDecorations)
{
NumberOfPeople = numberOfPeople;
this.fancyDecorations = fancyDecorations;
SetHealthyOption(healthyOption);
CalculateCostOfDecorations(fancyDecorations);
That's my understanding of what these lines of code do: First, NumberOfPeople gets set trough the "set" Methode.
private int numberOfPeople;
public int NumberOfPeople
{
get
{
return numberOfPeople;
}
set
{
numberOfPeople = value;
CalculateCostOfDecorations(fancyDecorations);
}
When NumberOfPeople gets set, the CalculateCostOfDecorations Methode is called - with a parameter that hasn't been set yet. Shouldn't this result in an error? What am I missing here?
The additional question is about the line " this.fancyDecorations = fancyDecorations;" in the constructor. Is this really necessary? Because fancyDecorations gets set anyway by the CalculateCostOfDecorations-Method that is called right afterwards. Again, am I missing something? :-)
Many thanks in advance for any input you might have.












