6 Lists and type checking
-
If needed, retrieve the OOP Company project up to chapter 5 from DLO. It contains the classes as you left them at the end of chapter 5.
-
Keep the array with four departments as in your
Mainmethod. -
Create a
List<Person>namedpeople. -
Fill the list as follows:
1 2 3 4 5 6 7
people.Add(new Employee("Mark", "Den Haag", departments[2], 10000)); people.Add(new Employee("Angelique", "Rotterdam", departments[2], 5000)); people.Add(new Employee("Caroline", "Delft", departments[1], 4000)); people.Add(new Freelancer("Klaas", "Diemen", departments[3], 50.00)); people.Add(new Freelancer("Ronald", "Zaandam", departments[0], 80.00)); people.Add(new Freelancer("Jannie", "Utrecht", departments[0], 60.00)); people.Add(new Freelancer("Anne", "Zwolle", departments[0], 40.00)); -
Use a for-loop with
isand casting to hire all freelancers in the list for 320 hours. -
Use a for-loop and the existing
ShowYearlyIncome()method to get the following output:1 2 3 4 5 6 7
Mark earns 130000,00 per year Angelique earns 65000,00 per year Caroline earns 48000,00 per year Klaas earns 16000,00 per year Ronald earns 25600,00 per year Jannie earns 19200,00 per year Anne earns 12800,00 per year