2 Encapsulation and constructor chaining
-
Continue with the project from the previous chapter. It contains the
ProgramandPersonclasses as you left them there. -
Change the
Personclass according to the class diagram below:a) Add the constant
BonusThreshold.
b) Make the four non-static attributes private.
c) Add properties for these four attributes (properties are not shown in the class diagram).
d) Apply constructor chaining to the three constructors.
e) Add theHasRightToBonus()method. It returnstrueif the monthly salary is greater than or equal toBonusThreshold. -
Fix any errors that have arisen in your
Mainmethod (access the attributes via their properties). -
Remove the last two lines of code (both starting with
Console.WriteLine) and add code so that your output looks like this:1 2 3 4 5 6 7 8
0 1 1 2 2 4 Mark earns 10000,00 and has right to a bonus. Caroline earns 4000,00 and has no right to a bonus.