c#编程题 急 !!!!以编译时的多态的思想编写一个雇员薪资管理程序

c#编程题 急 !!!!以编译时的多态的思想编写一个雇员薪资管理程序 公司有实习员工和正式员工两类,他们有公共的属性:姓名年龄地址等,但有不同的薪资算法,实习员工的薪资是3000元,正式员工底薪加提成,底薪为5000,每卖出一个产品有50元提成

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Employee a = new Trainee(10);
            Console.WriteLine(Company.PayOff(a));
            Employee b = new RealEmployee(10);
            Console.WriteLine(Company.PayOff(b));
            Console.ReadKey();
        }
    }
    public class Employee
    {
        protected int salary=0,bonus=0;
        public int wages;
        public Employee(int sellsNumb)
        {          
            
        }
        public virtual int GetWages()
        {
            wages = this.salary;
            return wages;
        }
    }
    public class Trainee : Employee
    {
        public Trainee(int sellsNumb): base(sellsNumb)
        {
            this.salary = 3000;
        }
        public override int GetWages()
        {
            wages = this.salary;
            return wages;
        }
    }
    public class RealEmployee : Employee
    {
        public RealEmployee(int sellsNumb): base(sellsNumb)
        {
            this.salary = 5000;
            this.bonus = 50 * sellsNumb;
        }
        public override int GetWages()
        {
            wages = this.salary + this.bonus;
            return wages;
        }
    }
    public abstract class Company
    {
        public static int PayOff(Employee e)
        {
            return e.GetWages();
        }
    }

   
}


温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答