Exemple #1
0
        static void Main(string[] args)
        {
            //README If we create "BaseEmployee" class concrete (NON abstract) class, there is nothing stopping us from creating an instance of "BaseEmploye"
            //class. We only have two types of employees in our organization- Contract and FullTime. The developers should only be able to instantiate
            //ContractEmployee & FullTime classes and not BaseEmployee class.


            FullTimeEmployee fte = new FullTimeEmployee();

            fte.Id           = 1023;
            fte.FirstName    = "Mark";
            fte.LastName     = "Sul";
            fte.AnnualSalary = 60000;

            ContractEmployee cte = new ContractEmployee();

            cte.Id          = 1234;
            cte.FirstName   = "Kyle";
            cte.LastName    = "Mile";
            cte.HourlyPay   = 23;
            cte.HoursWorked = 50;

            Console.WriteLine(fte);
            Console.WriteLine(fte.GetMonthlySalary());
            Console.WriteLine(cte.GetMonthlySalary());
        }
Exemple #2
0
        static void Main(string[] args)
        {
            FullTimeEmployee fte = new FullTimeEmployee()
            {
                ID           = 101,
                FirstName    = "Mine",
                LastName     = "Quiquez",
                AnnualSalary = 120
            };

            Console.WriteLine(fte.GetFullName());
            Console.WriteLine("Salary: " + fte.GetMonthlySalary());

            ContractEmployee cte = new ContractEmployee()
            {
                ID         = 102,
                FirstName  = "John",
                LastName   = "Doe",
                HourlyPay  = 20,
                TotalHours = 40
            };

            Console.WriteLine(cte.GetFullName());
            Console.WriteLine("Salary: " + cte.GetMonthlySalary());
        }