注册 登录
编程论坛 C# 论坛

萌新上路,求助一道类库的问题,尽量详细一些

a154734817 发布于 2020-11-16 12:04, 1616 次点击
只有本站会员才能查看附件,请 登录
2 回复
#2
haitao00002020-11-18 11:47
public abstract class Employee
    {
        public  string name { get; set; }
        public  decimal earnings { get; set; }    //实发工资
        public  DateTime bornDay { get; set; }    //出生日期
        public abstract string Type { get; }              //职工职务
        public Employee() { }
        public Employee(string nm, int year, int month, int day)
        {
            name = nm;
            bornDay = new DateTime(year, month, day);
        }
        public abstract void Earnings();
        public virtual void Display()
        {
            //System.Globalization.CultureInfo zh_cul;
            //zh_cul = System.Globalization.CultureInfo.GetCultureInfo("zh");
            Console.WriteLine("职工名字:{0},出生日期:{1},职务:{2},工资:{3}", name, bornDay.ToString("yyyy//MM/dd"), Type, earnings.ToString("C2"));
        }
    }
    public class Manager : Employee
    {
        public double salary;     //基本工资
        public double bonus;     //资金
        public Manager() { }
        public Manager(string nm, int year, int month, int day, double sl, double bns) : base(nm, year, month, day)
        {
            salary = sl;
            bonus = bns;
        }
        public override void Earnings()
        {
            earnings = (decimal)(salary + bonus);
        }
            public override string Type
        {
            get { return Type; }
        }
        public override void Display()
        {
            base.Display();
            Console.WriteLine("基本工资:{0},资金:{1}.", salary.ToString("C2"), bonus.ToString("C2"));
        }
    }
#3
a1547348172020-11-22 18:36
已采纳
1