Beispiel #1
0
        static void Main(string[] args)
        {
            WageEmployee     wageEmployee1     = new WageEmployee("Billy", "Bob", 123, 15.50, 40);
            SalariedEmployee salariedEmployee1 = new SalariedEmployee("Mary", "Sue", 456, 85000);
            double           wage   = wageEmployee1.pay(wageEmployee1.Wage);
            double           salary = salariedEmployee1.pay(salariedEmployee1.AnnualSalary);

            Console.WriteLine($"{wageEmployee1.FirstName} {wageEmployee1.LastName} {wageEmployee1.EmployeeID} {wageEmployee1.Wage} Wage Employee");

            Console.WriteLine($"{wageEmployee1.FirstName} {wageEmployee1.LastName} makes { wageEmployee1.pay(wageEmployee1.Wage)} per week.");

            Console.WriteLine($"{salariedEmployee1.FirstName} {salariedEmployee1.LastName} {salariedEmployee1.EmployeeID} {salariedEmployee1.AnnualSalary} Salaried Employee");

            Console.WriteLine($"{salariedEmployee1.FirstName} {salariedEmployee1.LastName} makes {salary} per week.");

            Console.WriteLine($"{wageEmployee1.FirstName} is {wageEmployee1.talk(" ")}");

            Console.WriteLine($"{salariedEmployee1.FirstName} is {salariedEmployee1.talk(" ")}");
        }
Beispiel #2
0
        static void doWork()
        {
            try
            {
                WageEmployee     wageEmployee1     = new WageEmployee("Billy", "Bob", 123, 15.50, 40);
                SalariedEmployee salariedEmployee1 = new SalariedEmployee("Mary", "Sue", 456, 85000);
                double           wage   = wageEmployee1.pay(wageEmployee1.Wage); // Can set to a variable because the pay method returns a double
                double           salary = salariedEmployee1.pay(salariedEmployee1.AnnualSalary);

                wageEmployee1.addJob("Apprentice"); // "addJob" sets the value to Apprentice
                salariedEmployee1.addJob("Manager");

                Console.WriteLine($"{wageEmployee1.FirstName} {wageEmployee1.LastName} {wageEmployee1.EmployeeID} {wageEmployee1.Wage} Wage Employee");

                Console.WriteLine($"{wageEmployee1.FirstName} {wageEmployee1.LastName} makes { wageEmployee1.pay(wageEmployee1.Wage)} per week.");

                Console.WriteLine($"{salariedEmployee1.FirstName} {salariedEmployee1.LastName} {salariedEmployee1.EmployeeID} {salariedEmployee1.AnnualSalary} Salaried Employee");

                Console.WriteLine($"{salariedEmployee1.FirstName} {salariedEmployee1.LastName} makes {salary} per week.");

                Console.WriteLine($"{wageEmployee1.FirstName} is {wageEmployee1.talk(" ")}");

                Console.WriteLine($"{salariedEmployee1.FirstName} is {salariedEmployee1.talk(" ")}");

                Console.WriteLine($"{wageEmployee1.FirstName} is an {wageEmployee1.selectJob(" ")}");

                Console.WriteLine($"{salariedEmployee1.FirstName} is a {salariedEmployee1.selectJob(" ")}");

                // "selectJob" gets the value stored in the set "addJob"
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.WriteLine("You've reached your final destination...");
            }
        }