Exemple #1
0
        internal static int Main()
        {
            // Using an interface makes the code more flexible
            // but ensures at the same time that the commitments
            // of an Employee are fulfilled.
            IEmployable Max = new FullTimeEmployee()
            {
                FirstName    = "Max",
                LastName     = "Mustermann",
                AnnualSalary = 60000
            };

            Console.WriteLine($"{Max.GetFullName()} earns {Max.GetMonthlySalary()} per month.");
            Max.WorkOn();

            Console.WriteLine();

            IEmployable Moritz = new Freelancer()
            {
                FirstName   = "Moritz",
                LastName    = "Mustermann",
                HourlyWage  = 200,
                HoursWorked = 20
            };

            Console.WriteLine($"{Moritz.GetFullName()} worked {((Freelancer)Moritz).HoursWorked} hours and earned {Moritz.GetMonthlySalary()} last month.");
            Moritz.WorkOn();

            Console.WriteLine("\nProgram end reached. Press the any-key to exit.");
            Console.ReadKey();
            return(0);
        }
    public static void Main(string[] args)
    {
        //Console.WriteLine("Hello World");

        //abstract class initialisation is prevented during compile time.
        //BaseEmployee be =new BaseEmployee();

        FullTimeEmployee fte = new FullTimeEmployee()
        {
            ID           = 101,
            first_name   = "Arun",
            last_name    = "May",
            anual_salary = 10000
        };

        ContractEmployee cte = new ContractEmployee()
        {
            ID          = 102,
            first_name  = "Vel",
            last_name   = "murugan",
            total_hours = 40,
            months      = 12
        };


        Console.WriteLine(cte.GetFullName());
        Console.WriteLine(cte.GetMonthlySalary());


        Console.WriteLine(fte.GetFullName());
        Console.WriteLine(fte.GetMonthlySalary());
    }
Exemple #3
0
    public static void Main()
    {
        FullTimeEmployee fte = new FullTimeEmployee()
        {
            ID           = 123,
            FirstName    = "Mark",
            LastName     = "Zuckerberg",
            AnnualSalary = 200000
        };

        Console.WriteLine(fte.GetFullName());
        Console.WriteLine(fte.GetMonthlySalary());

        ContractEmployee cte = new ContractEmployee()
        {
            ID               = 123,
            FirstName        = "Charles",
            LastName         = "Babbage",
            HourlyPay        = 200,
            TotalHoursWorked = 40
        };

        Console.WriteLine(cte.GetFullName());
        Console.WriteLine(cte.GetMonthlySalary());
    }
Exemple #4
0
        static void Main(string[] args)
        {
            FullTimeEmployee fte = new FullTimeEmployee()
            {
                ID           = 101,
                FirstName    = "Joe",
                LastName     = "Smith",
                AnnualSalary = 60000
            };

            Console.WriteLine($"Get full name: {fte.GetFullName()},  Annual Salary: {fte.GetMonthlySalary()}");
            Console.WriteLine("------------------------------------------------");

            ContractEmployee cte = new ContractEmployee()
            {
                ID         = 102,
                FirstName  = "Sarah",
                LastName   = "Jones",
                HourlyPay  = 50,
                TotalHours = 40 * 4
            };

            Console.WriteLine($"Get full name: {cte.GetFullName()},  Annual Salary: {cte.GetMonthlySalary()}");
            Console.WriteLine("------------------------------------------------");
        }
        public static void Main()
        {
            FullTimeEmployee fte = new FullTimeEmployee()
            {
                ID           = 101,
                FirstName    = "Rick",
                LastName     = "Wenz",
                AnnualSalary = 60000
            };

            Console.WriteLine(fte.GetFullName());
            Console.WriteLine(fte.GetMonthlySalary());

            Console.WriteLine("-------------");

            ContractEmployee cte = new ContractEmployee()
            {
                ID               = 102,
                FirstName        = "Alex",
                LastName         = "Koppel",
                HourlyPay        = 100,
                TotalHoursWorked = 40
            };

            Console.WriteLine(cte.GetFullName());
            Console.WriteLine(cte.GetMonthlySalary());
            Console.ReadLine();
        }