CS 140 Week 7 Exercises
October 7 (Monday)
Complete exercise 9.6 on page 381, which I've reprinted here:
Write an inheritance heirarcy for classesQuadrilateral,Trapezoid,Parallelogram,Rectangle, andSquare. UseQuadrilateral as thebase of the hierarchy. Make the hierarchy as deep (i.e., as many levels) as possible. The private data ofQuadrilateralshould be the x-y coordinate pairs for the four endpoints of theQuadrilateral. Write a program that instantiates objects of each of the classes in your hierarcy and polymorphically outputs each object's dimensions and area.
- Your test program can be a console-mode program.
- Put all classes in the same file, including the test class.
- Submit your file as YourLoginIDEX7a.cs
October 9 (Wednesday)
Complete this modified version of Exercise 10.6 from page 437 in your textbook.
Modify the payroll system of Fig. 10.10-Fig. 10.14 to addprivateinstance variablesbirthDate(use classDayfrom Fig. 8.8) anddepartmentCode(an int) to classEmployee. Assume that the payroll is processed once a month. Create an arry ofEmployeereferences to store the variousEmployee objects. In a loop, calculate the payroll for each Employee (polymorphically) and add a $100.00 bonus to the person's payroll amount if this is the month in which theEmployee's birthday occurs.
- Download the starter file, Ex07b.cs
- Make your array at least 10 elements long.
- Use a loop, a random number, and a switch to decide which constructor to call.
- Save the file as YourLoginIDEx07b.cs
- drop it in my Submissions folder before you leave.