From the course: Advanced C#: Object-Oriented Programming
Unlock the full course today
Join today to access over 24,600 courses taught by industry experts.
Solution: Abstract employee class - C# Tutorial
From the course: Advanced C#: Object-Oriented Programming
Solution: Abstract employee class
(upbeat music) - [Instructor] All right, let's review the requirements that we had for this challenge. First, we wanted to make sure that the Employee base class itself could not be instantiated. Next, we wanted to make sure that the AdjustPay method was required to be implemented by subclasses. And finally, we wanted to make sure that the Hourly and Salaried subclasses could not be subclassed themselves any further. All right, let's open up my solution code to this. So for the first part, we just need to modify our class definition for Employee to include the abstract keyword. This prevents the Employee class from being instantiated itself. The abstract keyword also helps us solve the second requirement. We defined AdjustPay as abstract and subclasses of Employee now have to provide their own implementation. And if we look down in Hourly and SalariedEmployee we can see that that is the case. They both have their own…