예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** The Employee Class Hierarchy ******\n");
            Manager chucky = new Manager("Chucky", 50, 92, 10000, "333-23-23222", 9000);

            chucky.GiveBonus(300);
            chucky.DisplayStats();
            Console.WriteLine();
            Salesperson fran = new Salesperson("Fran", 43, 93, 3000, "932-32-3232", 31);

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

            CastingExamples();

            Console.ReadLine();
        }
예제 #2
0
        static void CastingExamples()
        {
            object   frank    = new Manager("Frank Zappa", 9, 3000, 40000, "111-11-1111", 5);
            Employee moonUnit = new Manager("MoonUnit Zappa", 2, 3001, 20000, "101-11-1321", 1);

            GivePromotion(moonUnit);
            Salesperson   jill     = new PTSalesPerson("Jill", 834, 3002, 100000, "111-12-1119", 90, 4);
            PTSalesPerson TestPTSP = new PTSalesPerson("TestPTSP", 22, 99, 20000, "13337", 20, 4);

            GivePromotion((Manager)frank);
            GivePromotion((Salesperson)TestPTSP);

            Salesperson sp = frank as Salesperson;

            if (sp == null)
            {
                Console.WriteLine("Sorry, frank is not a salesperson...");
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            Salesperson fred = new Salesperson();

            fred.Age         = 31;
            fred.Name        = "Fred";
            fred.SalesNumber = 50;
            PTSalesperson genry = new PTSalesperson("Genry", 19, 2, 16000, "652114", 0);

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

            Console.WriteLine("Benefits: {0}", cost);
            chucky.DisplayStats();
            Console.ReadLine();
        }
예제 #4
0
파일: Program.cs 프로젝트: mamihaylov/Class
        static void CastingExamples()
        {
            object frank = new Manager("Frank Zappa", 9, 3000, 40000, "111-11-1111", 5);

            GivePromotion((Manager)frank);
            Employee moonUnit = new Manager("MoonUnit Zappa", 2, 3001, 20000, "101-11-1321", 1);

            GivePromotion(moonUnit);
            //PtSalesPerson "является" SalesPerson
            Salesperson jill = new PTSalesPerson("Jill", 834, 3002, 100000, "111 - 12 - 1119", 90);

            GivePromotion(jill);
            // Использование as для проверки соместимости.
            Salesperson hex2 = frank as Salesperson;

            if (hex2 == null)
            {
                Console.WriteLine("Sorry, frank is not a Salesperson");
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** The Employee Class Hierarchy ******\n");
            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();

            Console.WriteLine("Chucky benefit cost: {0}", cost);

            PTSalesPerson TestPTSP = new PTSalesPerson("Alex", 24, 93, 500000, "1337-1337", 4000, 4);

            Console.WriteLine("SalesPerson {0} works {1} hours / day", TestPTSP.Name, TestPTSP.WorkHours);


            Console.ReadLine();
        }