static void Main()
    {
        // instantiate CommissionEmployee object
        var employee = new CommissionEmployee("Sue", "Jones",
                                              "222-22-2222", 10000.00M, .06M);

        // display CommissionEmployee data
        Console.WriteLine(
            "Employee information obtained by properties and methods: \n");
        Console.WriteLine($"First name is {employee.FirstName}");
        Console.WriteLine($"Last name is {employee.LastName}");
        Console.WriteLine(
            $"Social security number is {employee.SocialSecurityNumber}");
        Console.WriteLine($"Gross sales are {employee.GrossSales:C}");
        Console.WriteLine(
            $"Commission rate is {employee.CommissionRate:F2}");
        Console.WriteLine($"Earnings are {employee.Earnings():C}");

        employee.GrossSales     = 5000.00M; // set gross sales
        employee.CommissionRate = .1M;      // set commission rate

        Console.WriteLine(
            "\nUpdated employee information obtained by ToString:\n");
        Console.WriteLine(employee);
        Console.WriteLine($"earnings: {employee.Earnings():C}");
    }
    public static void Main( string[] args )
    {
        // instantiate CommissionEmployee object
          CommissionEmployee employee = new CommissionEmployee( "Sue",
         "Jones", "222-22-2222", 10000.00M, .06M );

          // display commission employee data
          Console.WriteLine(
         "Employee information obtained by properties and methods: \n" );
          Console.WriteLine( "First name is {0}", employee.FirstName );
          Console.WriteLine( "Last name is {0}", employee.LastName );
          Console.WriteLine( "Social security number is {0}",
         employee.SocialSecurityNumber );
          Console.WriteLine( "Gross sales are {0:C}", employee.GrossSales );
          Console.WriteLine( "Commission rate is {0:F2}",
         employee.CommissionRate );
          Console.WriteLine( "Earnings are {0:C}", employee.Earnings() );

          employee.GrossSales = 5000.00M; // set gross sales
          employee.CommissionRate = .1M; // set commission rate

          Console.WriteLine( "\n{0}:\n\n{1}",
         "Updated employee information obtained by ToString", employee );
          Console.WriteLine( "earnings: {0:C}", employee.Earnings() );
    }
Exemple #3
0
    public static void Main(string[] args)
    {
        // instantiate CommissionEmployee object
        CommissionEmployee employee = new CommissionEmployee("Sue",
                                                             "Jones", "222-22-2222", 10000.00M, .06M);

        // display commission employee data
        Console.WriteLine(
            "Employee information obtained by properties and methods: \n");
        Console.WriteLine("First name is {0}", employee.FirstName);
        Console.WriteLine("Last name is {0}", employee.LastName);
        Console.WriteLine("Social security number is {0}",
                          employee.SocialSecurityNumber);
        Console.WriteLine("Gross sales are {0:C}", employee.GrossSales);
        Console.WriteLine("Commission rate is {0:F2}",
                          employee.CommissionRate);
        Console.WriteLine("Earnings are {0:C}", employee.Earnings());

        employee.GrossSales     = 5000.00M; // set gross sales
        employee.CommissionRate = .1M;      // set commission rate

        Console.WriteLine("\n{0}:\n\n{1}",
                          "Updated employee information obtained by ToString", employee);
        Console.WriteLine("Earnings: {0:C}", employee.Earnings());
    } // end Main
    static void Main()
    {
        // create derived-class objects
        var salariedEmployee = new SalariedEmployee("John", "Smith",
                                                    "111-11-1111", 800.00M);
        var hourlyEmployee = new HourlyEmployee("Karen", "Price",
                                                "222-22-2222", 16.75M, 40.0M);
        var commissionEmployee = new CommissionEmployee("Sue", "Jones",
                                                        "333-33-3333", 10000.00M, .06M);
        var basePlusCommissionEmployee =
            new BasePlusCommissionEmployee("Bob", "Lewis",
                                           "444-44-4444", 5000.00M, .04M, 300.00M);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine($"{salariedEmployee}\nearned: " +
                          $"{salariedEmployee.Earnings():C}\n");
        Console.WriteLine(
            $"{hourlyEmployee}\nearned: {hourlyEmployee.Earnings():C}\n");
        Console.WriteLine($"{commissionEmployee}\nearned: " +
                          $"{commissionEmployee.Earnings():C}\n");
        Console.WriteLine($"{basePlusCommissionEmployee}\nearned: " +
                          $"{basePlusCommissionEmployee.Earnings():C}\n");

        // create List<Employee> and initialize with employee objects
        var employees = new List <Employee>()
        {
            salariedEmployee,
            hourlyEmployee, commissionEmployee, basePlusCommissionEmployee
        };

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in employees
        foreach (var currentEmployee in employees)
        {
            Console.WriteLine(currentEmployee); // invokes ToString

            // determine whether element is a BasePlusCommissionEmployee
            if (currentEmployee is BasePlusCommissionEmployee)
            {
                // downcast Employee reference to
                // BasePlusCommissionEmployee reference
                var employee = (BasePlusCommissionEmployee)currentEmployee;

                employee.BaseSalary *= 1.10M;
                Console.WriteLine("new base salary with 10% increase is: " +
                                  $"{employee.BaseSalary:C}");
            }

            Console.WriteLine($"earned: {currentEmployee.Earnings():C}\n");
        }

        // get type name of each object in employees
        for (int j = 0; j < employees.Count; j++)
        {
            Console.WriteLine(
                $"Employee {j} is a {employees[j].GetType()}");
        }
    }
    public static void Main(string[] args)
    {
        CommissionEmployee employee = new CommissionEmployee("Sue", "Jones", "222-22-222", 10000.00M, .06M);

        Console.WriteLine("Employee information obtained by properties and methods: \n");
        Console.WriteLine("{0} {1}", "First name is", employee.FirstName);
        Console.WriteLine("{0} {1}", "Last name is", employee.LastName);
        Console.WriteLine("{0} {1}", "Social security number is", employee.SocialSecurityNumber);
        Console.WriteLine("{0} {1}", "Gross sales are", employee.GrossSales);
        Console.WriteLine("{0} {1}", "Commission rate is", employee.CommissionRate);
        Console.WriteLine("{0} {1}", "Earnings are", employee.Earnings());

        employee.GrossSales     = 5000.00M;
        employee.CommissionRate = .1M;

        Console.WriteLine("\n{0}:\n\n{1}", "Updated employee information obtained by ToString", employee);
        Console.WriteLine("earnings: {0:C}", employee.Earnings());
        Console.ReadKey();
    }
Exemple #6
0
    public static void Main(string[] args)
    {
        CommissionEmployee employeeC = new CommissionEmployee();

        employeeC.setData("Terry", "Harbos", 100523153, 300.25, 0.08);
        Console.WriteLine(employeeC.ToString());
        Console.WriteLine("Earnings: " + employeeC.Earnings());

        BasePlusComissionEmployee employeeB = new BasePlusComissionEmployee("Terry", "Harbos", 100523153, 300.25, 0.10, 25.00);

        Console.WriteLine("Earnings: " + employeeB.Earnings());
    }
Exemple #7
0
    static void Main()
    {
        Console.WriteLine("(01) Empleado por Comision\n");

        var employee = new CommissionEmployee("Sue", "Jones",
                                              "222-22-2222", 1000.00M, .06M);

        Console.WriteLine("Informacion del empleado obtenida por las propiedades y metodos: \n");
        Console.WriteLine("Nombre                  : {0}", employee.FirstName);
        Console.WriteLine("Apellido                : {0}", employee.LastName);
        Console.WriteLine("Numero de Seguro Social : {0}", employee.SocialSecurityNumber);
        Console.WriteLine("Ventas Brutas           : {0}", employee.GrossSales);
        Console.WriteLine("Porcentaje de Comision  : {0}", employee.CommissionRate);
        Console.WriteLine("Ganancias               : {0}", employee.Earnings());

        employee.GrossSales     = 5000.00M; // Se actualiza las ventas brutas del empleado
        employee.CommissionRate = .1M;      // Se actualiza el porcentaje de comision del empleado

        Console.WriteLine("\n" + "Informacion actualizada obtenida por :" + "\n" + employee.ToString() + "\n");
        Console.WriteLine(employee);
        Console.WriteLine("Ganancias               : {0}\n", employee.Earnings());
    }
Exemple #8
0
        public static void Main(string[] args)
        {
            SalariedEmployee salariedEmployee =
                new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
            HourlyEmployee hourlyEmployee =
                new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75M, 40.0M);
            CommissionEmployee commissionEmployee =
                new CommissionEmployee("Sue", "Jonse", "333-33-333", 10000.00M, .06M);
            BasePlusCommissionEmployee basePlusCommissionEmployee =
                new BasePlusCommissionEmployee("Bob", "Lewis", "444-44-4444", 5000.00M, .04M, 300.00M);

            Console.WriteLine("Employees processed individually:\n");

            Console.WriteLine("{0}\nearned: {1:C}\n", salariedEmployee, salariedEmployee.Earnings());
            Console.WriteLine("{0}\nearned: {1:C}\n", hourlyEmployee, hourlyEmployee.Earnings());
            Console.WriteLine("{0}\nearned: {1:C}\n", commissionEmployee, commissionEmployee.Earnings());
            Console.WriteLine("{0}\nearned: {1:C}\n", basePlusCommissionEmployee, basePlusCommissionEmployee.Earnings());

            Employee[] employees = new Employee[4];

            employees[0] = salariedEmployee;
            employees[1] = hourlyEmployee;
            employees[2] = commissionEmployee;
            employees[3] = basePlusCommissionEmployee;

            Console.WriteLine("Employees processed polymorphically:\n");

            foreach (Employee currentEmployee in employees)
            {
                Console.WriteLine(currentEmployee);

                if (currentEmployee is BasePlusCommissionEmployee)
                {
                    BasePlusCommissionEmployee employee =
                        (BasePlusCommissionEmployee)currentEmployee;

                    employee.BaseSalary *= 1.10M;

                    Console.WriteLine("new base salary with 10% increase is:{0:C}", employee.BaseSalary);
                }
                Console.WriteLine("earned {0:C}\n", currentEmployee.Earnings());
            }

            for (int j = 0; j < employees.Length; j++)
            {
                Console.WriteLine("Employee {0} is a {1}", j, employees[j].GetType());
            }
        }
Exemple #9
0
        static void Main(string[] args)
        {
            //  Test each class by entering employee via constructor and printing details
            HourlyEmployee Hire1 = new HourlyEmployee("Joe","Dunn","070723889",1000,40);
            Console.WriteLine(Hire1);
            Console.WriteLine("{0}\t {1}\n","Total earnings:",Hire1.Earnings());

            SalariedEmployee Hire2 = new SalariedEmployee("John", "Rex", "970723889", 80000);
            Console.WriteLine(Hire2);
            Console.WriteLine("{0}\t {1}\n", "Total earnings:", Hire2.Earnings());

            BasePlusCommissionEmployee Hire3 = new BasePlusCommissionEmployee("Reg", "Smith", "370723889", 10000, 1/5, 40000);
            Console.WriteLine(Hire3);
            Console.WriteLine("{0}\t {1}\n", "Total earnings:", Hire3.Earnings());

            CommissionEmployee Hire4 = new CommissionEmployee("Lisa", "Pepper", "170723889", 100000, 1 / 5);
            Console.WriteLine(Hire4);
            Console.WriteLine("{0}\t {1}\n", "Total earnings:", Hire4.Earnings());

            Console.Read();
        }
    static void Main()
    {
        // assign base-class reference to base-class variable
        var commissionEmployee = new CommissionEmployee(
            "Sue", "Jones", "222-22-2222", 10000.00M, .06M);

        // assign derived-class reference to derived-class variable
        var basePlusCommissionEmployee = new BasePlusCommissionEmployee(
            "Bob", "Lewis", "333-33-3333", 5000.00M, .04M, 300.00M);

        // invoke ToString and Earnings on base-class object
        // using base-class variable
        Console.WriteLine(
            "Call CommissionEmployee's ToString and Earnings methods " +
            "with base-class reference to base class object\n");
        Console.WriteLine(commissionEmployee.ToString());
        Console.WriteLine($"earnings: {commissionEmployee.Earnings()}\n");

        // invoke ToString and Earnings on derived-class object
        // using derived-class variable
        Console.WriteLine("Call BasePlusCommissionEmployee's ToString and" +
                          " Earnings methods with derived class reference to" +
                          " derived-class object\n");
        Console.WriteLine(basePlusCommissionEmployee.ToString());
        Console.WriteLine(
            $"earnings: {basePlusCommissionEmployee.Earnings()}\n");

        // invoke ToString and Earnings on derived-class object
        // using base-class variable
        CommissionEmployee commissionEmployee2 = basePlusCommissionEmployee;

        Console.WriteLine(
            "Call BasePlusCommissionEmployee's ToString and Earnings " +
            "methods with base class reference to derived-class object\n");
        Console.WriteLine(commissionEmployee2.ToString());
        Console.WriteLine(
            $"earnings: {basePlusCommissionEmployee.Earnings()}\n");
    }
Exemple #11
0
    public static void Main(string[] args)
    {
        // assign base class reference to base class variable
        CommissionEmployee commissionEmployee = new CommissionEmployee(
            "Sue", "Jones", "222-22-2222", 10000.00M, .06M);

        // assign derived class reference to derived class variable
        BasePlusCommissionEmployee basePlusCommissionEmployee =
            new BasePlusCommissionEmployee("Bob", "Lewis",
                                           "333-33-3333", 5000.00M, .04M, 300.00M);

        // invoke ToString and Earnings on base class object
        // using base class variable
        Console.WriteLine("{0} {1}:\n\n{2}\n{3}: {4:C}\n",
                          "Call CommissionEmployee's ToString and Earnings methods",
                          "with base class reference to base class object",
                          commissionEmployee.ToString(),
                          "Earnings", commissionEmployee.Earnings());

        // invoke ToString and Earnings on derived class object
        // using derived class variable
        Console.WriteLine("{0} {1}:\n\n{2}\n{3}: {4:C}\n",
                          "Call BasePlusCommissionEmployee's ToString and Earnings",
                          "methods with derived class reference to derived class object",
                          basePlusCommissionEmployee.ToString(),
                          "Earnings", basePlusCommissionEmployee.Earnings());

        // invoke ToString and Earnings on derived class object
        // using base class variable
        CommissionEmployee commissionEmployee2 =
            basePlusCommissionEmployee;

        Console.WriteLine("{0} {1}:\n\n{2}\n{3}: {4:C}",
                          "Call BasePlusCommissionEmployee's ToString and Earnings",
                          "methods with base class reference to derived class object",
                          commissionEmployee2.ToString(), "Earnings",
                          commissionEmployee2.Earnings());
    } // end Main
Exemple #12
0
    static void Main()
    {
        // create derived-class objects
        var salariedEmployee = new SalariedEmployee("John", "Smith",
                                                    "111-11-1111", 800.00M);
        var hourlyEmployee = new HourlyEmployee("Karen", "Price",
                                                "222-22-2222", 16.75M, 40.0M);
        var commissionEmployee = new CommissionEmployee("Sue", "Jones",
                                                        "333-33-3333", 10000.00M, .06M);
        var basePlusCommissionEmployee =
            new BasePlusCommissionEmployee("Bob", "Lewis",
                                           "444-44-4444", 5000.00M, .04M, 300.00M);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine($"{salariedEmployee}\nearned: " +
                          $"{salariedEmployee.Earnings():C}\n");
        Console.WriteLine(
            $"{hourlyEmployee}\nearned: {hourlyEmployee.Earnings():C}\n");
        Console.WriteLine($"{commissionEmployee}\nearned: " +
                          $"{commissionEmployee.Earnings():C}\n");
        Console.WriteLine($"{basePlusCommissionEmployee}\nearned: " +
                          $"{basePlusCommissionEmployee.Earnings():C}\n");

        // create List<Employee> and initialize with employee objects
        var employees = new List <Employee>()
        {
            salariedEmployee,
            hourlyEmployee, commissionEmployee, basePlusCommissionEmployee
        };

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in employees
        foreach (var currentEmployee in employees)
        {
            Console.WriteLine(currentEmployee); // invokes ToString

            // determine whether element is a BasePlusCommissionEmployee
            if (currentEmployee is BasePlusCommissionEmployee)
            {
                // downcast Employee reference to
                // BasePlusCommissionEmployee reference
                var employee = (BasePlusCommissionEmployee)currentEmployee;

                employee.BaseSalary *= 1.10M;
                Console.WriteLine("new base salary with 10% increase is: " +
                                  $"{employee.BaseSalary:C}");
            }

            Console.WriteLine($"earned: {currentEmployee.Earnings():C}\n");
        }

        // get type name of each object in employees
        for (int j = 0; j < employees.Count; j++)
        {
            Console.WriteLine(
                $"Employee {j} is a {employees[j].GetType()}");
        }

        Console.WriteLine("-----------------Beginnig of Question 3 answer");
        Console.WriteLine("-----------------by Jovane Marques - 300982100");
        var employeesNewSalary = employees.Select(e =>
                                                  new
        {
            FullName = e.FirstName + " " + e.LastName,
            Salary   = e is BasePlusCommissionEmployee ? ((e as BasePlusCommissionEmployee).BaseSalary * Decimal.Parse("1.1")) : e.Earnings()
        });

        foreach (var emp in employeesNewSalary)
        {
            Console.WriteLine("Employee: " + emp.FullName + ", Salary = " + emp.Salary);
        }
        Console.WriteLine("-----------------End of Question 3 answer");

        Console.ReadKey();
    }
    static void Main()
    {
        var date1                      = new Date(1, 1, 1989);
        var birthday                   = new Date(2, 9, 1989);
        var salariedEmployee           = new SalariedEmployee("John", "Smith", "111-11-1111", 800.00m, birthday);
        var hourlyEmployee             = new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75m, 40.0m, birthday);
        var commissionEmployee         = new CommissionEmployee("Sue", "Jones", "333-33-3333", 10000.00m, .06m, birthday);
        var basePlusCommissionEmployee = new BasePlusCommissionEmployee("Bob", "Lewis", "444-44-4444", 5000.00m, .04m, 300.00m, birthday);
        var pieceWorker2               = new PieceWorker("Brian", "Briansen", "555-55-5555", .40m, 1000, birthday);

        birthday = new Date(4, 9, 1989);
        var pieceWorker = new PieceWorker("Brian", "Briansen", "555-55-5555", .40m, 1000, birthday);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine($"{salariedEmployee}\nearned: " +
                          $"{salariedEmployee.Earnings():C}\n");
        Console.WriteLine($"{hourlyEmployee}\nearned: " +
                          $"{hourlyEmployee.Earnings():C}\n");
        Console.WriteLine($"{commissionEmployee}\nearned: " +
                          $"{commissionEmployee.Earnings():C}\n");
        Console.WriteLine($"{basePlusCommissionEmployee}\nearned: " +
                          $"{basePlusCommissionEmployee.Earnings():C}\n");
        Console.WriteLine($"{pieceWorker}\nearned: " +
                          $"{pieceWorker.Earnings():C}");

        var employees = new List <Employee>()
        {
            salariedEmployee, hourlyEmployee, commissionEmployee, basePlusCommissionEmployee, pieceWorker2, pieceWorker
        };

        Console.WriteLine("\nEmployees processed polymorphically: \n");
        for (int month = 1; month < 12; month++)
        {
            foreach (var currentEmployee in employees)
            {
                Console.WriteLine(currentEmployee);
                if (currentEmployee is BasePlusCommissionEmployee)
                {
                    var employee = (BasePlusCommissionEmployee)currentEmployee;

                    employee.BaseSalary *= 1.10m;
                    Console.WriteLine("new base salary with 10% increase is: " +
                                      $"{employee.BaseSalary:C}");
                }
                if (month == currentEmployee.Birthday.Month)
                {
                    Console.WriteLine("Birthday Bonus: 100.00");
                    Console.WriteLine($"earned {currentEmployee.Earnings() + 100:C}\n");
                }
                else
                {
                    Console.WriteLine($"earned {currentEmployee.Earnings():C}\n");
                }
            }
        }


        for (int j = 0; j < employees.Count; j++)
        {
            Console.WriteLine($"Employee {j} is a {employees[j].GetType()}");
        }

        Console.ReadLine();
    }
    public static void Main(string[] args)
    {
        // create derived class objects
        SalariedEmployee salariedEmployee =
            new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
        HourlyEmployee hourlyEmployee =
            new HourlyEmployee("Karen", "Price",
                               "222-22-2222", 16.75M, 40.0M);
        CommissionEmployee commissionEmployee =
            new CommissionEmployee("Sue", "Jones",
                                   "333-33-3333", 10000.00M, .06M);
        BasePlusCommissionEmployee basePlusCommissionEmployee =
            new BasePlusCommissionEmployee("Bob", "Lewis",
                                           "444-44-4444", 5000.00M, .04M, 300.00M);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine("{0}\nearned: {1:C}\n",
                          salariedEmployee, salariedEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          hourlyEmployee, hourlyEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          commissionEmployee, commissionEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          basePlusCommissionEmployee,
                          basePlusCommissionEmployee.Earnings());

        // create four-element Employee array
        Employee[] employees = new Employee[4];

        // initialize array with Employees of derived types
        employees[0] = salariedEmployee;
        employees[1] = hourlyEmployee;
        employees[2] = commissionEmployee;
        employees[3] = basePlusCommissionEmployee;

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in array employees
        processEmployees(employees);

        // get type name of each object in employees array
        for (int j = 0; j < employees.Length; j++)
        {
            Console.WriteLine("Employee {0} is a {1}", j,
                              employees[j].GetType());
        }

        Console.WriteLine("\nEMPLOYEES PROCESSED BY IPAYABLE\n");

        //Create IPayable array
        IPayable[] payableObjects = new IPayable[8];
        payableObjects[0] = new SalariedEmployee(
            "John", "Smith", "111-11-1111", 700M);
        payableObjects[1] = new SalariedEmployee(
            "Antonio", "Smith", "555-55-5555", 800M);
        payableObjects[2] = new SalariedEmployee(
            "Victor", "Smith", "444-44-4444", 600M);
        payableObjects[3] = new HourlyEmployee(
            "Karen", "Price", "222-22-2222", 16.75M, 40M);
        payableObjects[4] = new HourlyEmployee(
            "Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
        payableObjects[5] = new CommissionEmployee(
            "Sue", "Jones", "333-33-3333", 10000M, .06M);
        payableObjects[6] = new BasePlusCommissionEmployee(
            "Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
        payableObjects[7] = new BasePlusCommissionEmployee(
            "Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

        // generically process each element in array employees
        processEmployees(payableObjects);

        //bubble sort and pointer
        Console.WriteLine("\nIPAYABLES SORTED BY SSN:\n");
        BubbleSort(payableObjects, SSNAscending);
        foreach (Employee currentEmployee in payableObjects)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparer
        Console.WriteLine("\nIPAYABLES SORTED BY LAST NAME ASCENDING\n");
        ArrayList comparerSample = new ArrayList();

        //populate ArrayList for IComparer and IComprable
        foreach (IPayable currentPayable in payableObjects)
        {
            comparerSample.Add(currentPayable);
        }//end foreach
        IComparer lastAscend = new SortLastNAscending();

        comparerSample.Sort(lastAscend);
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparable implementation
        Console.WriteLine("\nIPAYABLES SORTED BY SALARY DESCEDNING\n");
        comparerSample.Sort();
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach
    }     // end Main
    public static void Main(string[] args)
    {
        // create derived class objects
        SalariedEmployee salariedEmployee =
           new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
        HourlyEmployee hourlyEmployee =
           new HourlyEmployee("Karen", "Price",
           "222-22-2222", 16.75M, 40.0M);
        CommissionEmployee commissionEmployee =
           new CommissionEmployee("Sue", "Jones",
           "333-33-3333", 10000.00M, .06M);
        BasePlusCommissionEmployee basePlusCommissionEmployee =
           new BasePlusCommissionEmployee("Bob", "Lewis",
           "444-44-4444", 5000.00M, .04M, 300.00M);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine("{0}\nearned: {1:C}\n",
           salariedEmployee, salariedEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
           hourlyEmployee, hourlyEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
           commissionEmployee, commissionEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
           basePlusCommissionEmployee,
           basePlusCommissionEmployee.Earnings());

        // create four-element Employee array
        Employee[] employees = new Employee[4];

        // initialize array with Employees of derived types
        employees[0] = salariedEmployee;
        employees[1] = hourlyEmployee;
        employees[2] = commissionEmployee;
        employees[3] = basePlusCommissionEmployee;

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in array employees
        processEmployees(employees);

        // get type name of each object in employees array
        for (int j = 0; j < employees.Length; j++)
            Console.WriteLine("Employee {0} is a {1}", j,
               employees[j].GetType());

        Console.WriteLine("\nEMPLOYEES PROCESSED BY IPAYABLE\n");

        //Create IPayable array
        IPayable[] payableObjects = new IPayable[8];
        payableObjects[0] = new SalariedEmployee(
                "John", "Smith", "111-11-1111", 700M);
        payableObjects[1] = new SalariedEmployee(
                "Antonio", "Smith", "555-55-5555", 800M);
        payableObjects[2] = new SalariedEmployee(
                "Victor", "Smith", "444-44-4444", 600M);
        payableObjects[3] = new HourlyEmployee(
                "Karen", "Price", "222-22-2222", 16.75M, 40M);
        payableObjects[4] = new HourlyEmployee(
                "Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
        payableObjects[5] = new CommissionEmployee(
                "Sue", "Jones", "333-33-3333", 10000M, .06M);
        payableObjects[6] = new BasePlusCommissionEmployee(
                "Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
        payableObjects[7] = new BasePlusCommissionEmployee(
                "Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

        // generically process each element in array employees
        processEmployees(payableObjects);

        //bubble sort and pointer
        Console.WriteLine("\nIPAYABLES SORTED BY SSN:\n");
        BubbleSort(payableObjects, SSNAscending);
        foreach (Employee currentEmployee in payableObjects)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
               "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparer
        Console.WriteLine("\nIPAYABLES SORTED BY LAST NAME ASCENDING\n");
        ArrayList comparerSample = new ArrayList();
        //populate ArrayList for IComparer and IComprable
        foreach (IPayable currentPayable in payableObjects)
        {
            comparerSample.Add(currentPayable);
        }//end foreach
        IComparer lastAscend = new SortLastNAscending();
        comparerSample.Sort(lastAscend);
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
               "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparable implementation
        Console.WriteLine("\nIPAYABLES SORTED BY SALARY DESCEDNING\n");
        comparerSample.Sort();
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
               "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach
    }
    public static void Main(string[] args)
    {
        // create derived class objects
        SalariedEmployee salariedEmployee =
            new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
        HourlyEmployee hourlyEmployee =
            new HourlyEmployee("Karen", "Price",
                               "222-22-2222", 16.75M, 40.0M);
        CommissionEmployee commissionEmployee =
            new CommissionEmployee("Sue", "Jones",
                                   "333-33-3333", 10000.00M, .06M);
        BasePlusCommissionEmployee basePlusCommissionEmployee =
            new BasePlusCommissionEmployee("Bob", "Lewis",
                                           "444-44-4444", 5000.00M, .04M, 300.00M);
        HourlyShiftEmployee hourlyShiftEmployee1 = new HourlyShiftEmployee("Nick", "Schuler", "111-22-3333", 10.00m, 30, 2);
        HourlyShiftEmployee hourlyShiftEmployee2 = new HourlyShiftEmployee("George", "Of The Jungle", "000-00-0000", 20.00m, 40, 3);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine("{0}\nearned: {1:C}\n",
                          salariedEmployee, salariedEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          hourlyEmployee, hourlyEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          commissionEmployee, commissionEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          basePlusCommissionEmployee,
                          basePlusCommissionEmployee.Earnings());
        Console.WriteLine("{0}\nEarned: {1:C}\n",
                          hourlyShiftEmployee1, hourlyShiftEmployee1.Earnings());
        Console.WriteLine("{0}\nEarned: {1:C}\n", hourlyShiftEmployee2, hourlyShiftEmployee2.Earnings());

        // create four-element Employee array
        Employee[] employees = new Employee[6];

        // initialize array with Employees of derived types
        employees[0]  = salariedEmployee;
        employees[1]  = hourlyEmployee;
        employees[2]  = commissionEmployee;
        employees[3]  = basePlusCommissionEmployee;
        employees [4] = hourlyShiftEmployee1;
        employees [5] = hourlyShiftEmployee2;

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in array employees
        foreach (Employee currentEmployee in employees)
        {
            Console.WriteLine(currentEmployee); // invokes ToString

            // determine whether element is a BasePlusCommissionEmployee
            if (currentEmployee is BasePlusCommissionEmployee)
            {
                // downcast Employee reference to
                // BasePlusCommissionEmployee reference
                BasePlusCommissionEmployee employee =
                    ( BasePlusCommissionEmployee )currentEmployee;

                employee.BaseSalary *= 1.10M;
                Console.WriteLine(
                    "new base salary with 10% increase is: {0:C}",
                    employee.BaseSalary);
            } // end if

            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        // get type name of each object in employees array
        for (int j = 0; j < employees.Length; j++)
        {
            Console.WriteLine("Employee {0} is a {1}", j,
                              employees[j].GetType());
        }
    } // end Main