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 classes Quadrilateral, Trapezoid, Parallelogram, Rectangle, and Square. Use Quadrilateral as the base of the hierarchy. Make the hierarchy as deep (i.e., as many levels) as possible. The private data of Quadrilateral should be the x-y coordinate pairs for the four endpoints of the Quadrilateral. Write a program that instantiates objects of each of the classes in your hierarcy and polymorphically outputs each object's dimensions and area.
  1. Your test program can be a console-mode program.
  2. Put all classes in the same file, including the test class.
  3. 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 add private instance variables birthDate (use class Day from Fig. 8.8) and departmentCode (an int) to class Employee. Assume that the payroll is processed once a month. Create an arry of Employee references to store the various Employee 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 the Employee's birthday occurs.
  1. Download the starter file, Ex07b.cs
  2. Make your array at least 10 elements long.
  3. Use a loop, a random number, and a switch to decide which constructor to call.
  4. Save the file as YourLoginIDEx07b.cs
  5. drop it in my Submissions folder before you leave.