Example #1
0
    public static void Main()
    {
        //class Inheritance
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.FirstName    = "Yuvi";
        FTE.LastName     = "cad";
        FTE.YearlySalary = 30000;
        FTE.PrintFullName();
        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.FirstName    = "Jack";
        PTE.LastName     = "Cloud";
        PTE.HourlySalary = 300;
        PTE.PrintFullName();

        //polymorphism

        CompanyEmployee[] employee = new CompanyEmployee[3];

        employee[0] = new CompanyEmployee();

        employee[1] = new CompanyFullTimeEmployee();
        employee[2] = new CompanyPartTimeEmployee();

        foreach (CompanyEmployee e in employee)
        {
            e.PrintEmployeeName();
        }
    }
Example #2
0
    public static void Main()
    {
        // whenever we creare an instance of a child class, we automatically create an instance of the base class
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.firstname = "Geetha";
        FTE._lastname = "Yedida";
        FTE.PrintFullName();
        FTE.YearlySalary = 15000F;

        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.firstname  = "Gee";
        PTE._lastname  = "Yed";
        PTE.HourlyRate = 13;
        PTE.PrintFullName();

        A A1 = new A();

        A1.YearlySalary = 1200;
        A1.PrintFullName();

        // it is also possible for the derived class constructor to control which of the constructors in the parent class is called. if the parent
        // class has more than one constructor.
    }
Example #3
0
    public static void Main()
    {
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.FirstName = "Ramesh";
        FTE.LastName  = "Jain";
        FTE.PrintFullName();

        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.FirstName = "Suresh";
        PTE.LastName  = "Jain";
        PTE.PrintFullName();

        //Suppose we want to call the hidden Base class 'PrintFullName()' method then we can do it 3 ways
        //1. We can use 'base.PrintFullName()' in the inherited PrintFullName() method in derived class

        //2. We can typecast the derived class object to be act as Parent class object.
        //Since Derived class is a specialisation of Base class, it fullfills all responsibilities of Base class
        //Thus we can use it refer to hidden base class method

        ((Employee)PTE).PrintFullName();


        //3. Since Derived class fulfills all responsibility of Base class
        //We can assign Derived class object to Base class Reference
        //Thus the Base class reference always invokes hidden base class method as it has no idea about Derived class PrintName method

        Employee emp = new PartTimeEmployee();

        emp.FirstName = "Lavish";
        emp.LastName  = "Jain";
        emp.PrintFullName();
    }
Example #4
0
        static void Main(string[] args)
        {
            FullTimeEmployee FTE = new FullTimeEmployee();

            FTE.FirstName = "FullTime";
            FTE.LastName  = "Employee";
            FTE.PrintFullName();

            PartTimeEmployee PTE = new PartTimeEmployee();

            PTE.FirstName = "Parttime";
            PTE.LastName  = "Employee";
            PTE.PrintFullName();
        }
Example #5
0
    public static void Main()
    {
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.FirstName = "FullTime";
        FTE.LastName  = "Employee";
        FTE.PrintFullName();

        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.FirstName = "PartTime";
        PTE.LastName  = "Employee";
        PTE.PrintFullName();
    }
Example #6
0
    public static void Main()
    {
        FullTimeEmployee fte = new FullTimeEmployee();

        fte.firstName = "Dave";
        fte.lastName  = "Rodgers";
        fte.PrintFullName();

        PartTimeEmployee pte = new PartTimeEmployee();

        pte.firstName = "Mike";
        pte.lastName  = "Kaysen";
        pte.PrintFullName();
    }
Example #7
0
    public static void Main()
    {
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.FirstName = "FullTime";
        FTE.LastName  = "Employee";
        FTE.PrintFullName();

        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.FirstName = "PartTime";
        PTE.LastName  = "Employee";
        ((Employee)PTE).PrintFullName();
        //PTE.PrintFullName();

        Employee PTE2 = new PartTimeEmployee();

        PTE2.FirstName = "PartTime";
        PTE2.LastName  = "Employee";
        PTE2.PrintFullName();           //	Call the hidden method of base class
    }
Example #8
0
    static void Main()
    {
        FullTimeEmployee FTE1 = new FullTimeEmployee();

        FTE1.FirstName    = "Jo";
        FTE1.LastName     = "Jos";
        FTE1.Email        = "*****@*****.**";
        FTE1.YearlySalary = 50000;

        FTE1.PrintFullName();
        FTE1.PrintEmailID();
        FTE1.PrintYearlySalary();

        FullTimeEmployee FTE2 = new FullTimeEmployee("Bob", "Hook");

        FTE2.Email        = "*****@*****.**";
        FTE2.YearlySalary = 100000;

        FTE2.PrintFullName();
        FTE2.PrintEmailID();
        FTE2.PrintYearlySalary();

        Employee E = (Employee)FTE2;

        E.PrintFullName();                //This still prints the hidden method in base class.
        ((Employee)FTE2).PrintFullName(); //This still prints the hidden method in base class.

        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.FirstName  = "Jon";
        PTE.LastName   = "Dow";
        PTE.Email      = "*****@*****.**";
        PTE.HourlyRate = 50;

        PTE.PrintFullName();
        PTE.PrintEmailID();
        PTE.PrintHourlyRate();

        Console.ReadKey();
    }
Example #9
0
        static void Main(string[] args)
        {
            Employee FTE = new PartTimeEmployee();

            //FullTimeEmployee FTE = new FullTimeEmployee();

            FTE.FirstName = "Praveen";
            FTE.LastName  = "Prajapati";
            FTE.PrintFullName();


            PartTimeEmployee PTE = new PartTimeEmployee();

            PTE.FirstName = "Chandan";
            PTE.LastName  = "Prajapati";
            //PTE.PrintFullName();
            ((Employee)PTE).PrintFullName();



            Console.ReadKey();
        }