Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** The Employee Class Hierarchy *****\n");

            // Create a subclass object and access base class functionality.
            SalesPerson fred = new SalesPerson();

            fred.Age         = 31;
            fred.Name        = "Fred";
            fred.SalesNumber = 50;

            Manager chucky = new Manager("Chucky", 50, 92, 100000, "333-23-2322", 9000);
            double  cost   = chucky.GetBenefitCost();

            // Create and use the public inner class. OK!
            OuterClass.PublicInnerClass inner;
            inner = new OuterClass.PublicInnerClass();

            // Compiler Error! Cannot access the private class.
            //OuterClass.PrivateInnerClass inner2;
            //inner2 = new OuterClass.PrivateInnerClass();

            // Define my benefit level.
            Employee.BenefitPackage.BenefitPackageLevel myBenefitLevel = Employee.BenefitPackage.BenefitPackageLevel.Platinum;
            Console.WriteLine("BenefitPackageLevel: {0}", myBenefitLevel);
            Console.WriteLine();

            // Give each employee a bonus?
            chucky.GiveBonus(300);
            chucky.DisplayStats();
            Console.WriteLine();

            SalesPerson fran = new SalesPerson("Fran", 43, 93, 3000, "932-32-3232", 31);

            fran.GiveBonus(200);
            fran.DisplayStats();
            Console.WriteLine();

            // Error! Cannot create an instance of an abstract class!
            //Employee X = new Employee();

            CastingExamples();

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            SalesPerson fred = new SalesPerson();
            fred.Age = 31;
            fred.Name = "Fred";
            fred.SalesNumber = 50;

            Manager chucky = new Manager("Chucky", 50, 92, 100000, "3-33-11", 9000);
            double cost = chucky.GetBenefitsCost();
            

            chucky.GiveBonus(300);
            chucky.DisplayStats();
            Console.WriteLine();

            SalesPerson fran = new SalesPerson("Fran", 43, 93, 3000, "3-22-22", 31);
            fran.GiveBonus(200);
            fran.DisplayStats();

            OuterClass.PublicInnerClass inner = new OuterClass.PublicInnerClass(); //OK

            //Employee e = new Employee(); ERROR, abstract class
            Console.ReadLine();
        }