예제 #1
0
파일: Program.cs 프로젝트: Byt3B3at/MyOOP
        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());
    }
예제 #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());
    }
예제 #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("------------------------------------------------");
        }
예제 #5
0
        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();
        }