代码没错,输出错误,能看看怎么回事吗?
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()
{
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"));
}
}
public class salesman:Employee
{
public float salary,commission;
const float RATE=0.05F;
public salesman(string nm, int year, int Month, int day, float sl, float c)
: base(nm, year, Month, day)
{
salary = sl;
commission = c;
}
public override string Type
{
get { return "销售员"; }
}
public override void Earnings()
{
Console.WriteLine("earnings:{0:c2}",salary + commission * RATE);
}
public override void Display()
{
base.Display();
Console.WriteLine("基本工资:{0:f2}¥,销售额:{1:f2}¥", salary, commission);
Console.WriteLine("提成率:{0}%", RATE);
}
}
public class Timeworker : Employee
{
public readonly int hourwage = 15;
public int hours;
public Timeworker(string nm, int year, int Month, int day, int h)
: base(nm, year, Month, day)
{
hours = h;
}
public override string Type
{
get { return "计时工人"; }
}
public override void Earnings()
{
Console.WriteLine("earnings:{0:c2}",hourwage * hours + (hours - 40) * 1.5);
}
public override void Display()
{
base.Display();
Console.WriteLine("每小时工资:{0:f2}¥,工作小时数:{1}", hourwage, hours);
}
}
class Pieceman : Employee
{
public readonly int picePay = 15;
public int no;
public Pieceman(string nm, int year, int Month, int day, int o)
: base(nm, year, Month, day)
{
no = o;
}
public override string Type
{
get { return "计件工人"; }
}
public override void Earnings()
{
earnings = picePay * no;
}
public override void Display()
{
base.Display();
Console.WriteLine("每件工资:{0:f2}¥,产品件数:{1}", picePay, no);
}
}
public class test
{
static void Main(string[] args)
{
Manager M = new Manager("王云", 2001, 01, 15, 10000, 1500);
salesman S = new salesman("郑凯", 2000, 09, 02, 6000, 3000);
Timeworker T = new Timeworker("张翔", 2000, 03, 17, 3000);
Pieceman P = new Pieceman("张权", 2000, 02, 25, 300000);
M.Earnings();
M.Display();
S.Earnings();
S.Display();
T.Earnings();
T.Display();
P.Earnings();
P.Display();
}
}
}