C#作业一道,注释写的好的加分!
1、先定义一个雇员类employee,它含有两个私有数据成员:姓名,工资。六个公有函数:对两个数据成员分别进行读写的四个函数、print()(用于输出两个数据成员的值)以...
1、先定义一个雇员类employee,它含有两个私有数据成员:姓名,工资。六个公有函数:对两个数据成员分别进行读写的四个函数、print()(用于输出两个数据成员的值)以及一个构造函数(初始化数据成员)。
以employee类为基类派生出一个佣金雇员类commissionEmployee。在commissionEmployee类中有两个新的数据成员:销售额、提成。并且添加如下三个函数:
一个构造函数,用于初始化数据成员(注意要初始化基类部分数据成员);一个用于计算工资的函数,计算方法为工资=销售额 * 提成;重写Print函数,用于打印:姓名、工资、销售额、提成;
在主函数中定义commissionEmployee类的一个对象,对commissionEmployee类进行测试。(不用定义employee类的对象,不必对employee类进行测试)
写有细致注释,能帮我理解的,再加150,跪谢 展开
以employee类为基类派生出一个佣金雇员类commissionEmployee。在commissionEmployee类中有两个新的数据成员:销售额、提成。并且添加如下三个函数:
一个构造函数,用于初始化数据成员(注意要初始化基类部分数据成员);一个用于计算工资的函数,计算方法为工资=销售额 * 提成;重写Print函数,用于打印:姓名、工资、销售额、提成;
在主函数中定义commissionEmployee类的一个对象,对commissionEmployee类进行测试。(不用定义employee类的对象,不必对employee类进行测试)
写有细致注释,能帮我理解的,再加150,跪谢 展开
3个回答
展开全部
/// <summary>
/// 员工类
/// </summary>
class Employee
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="name">姓名</param>
/// <param name="salary">工资</param>
public Employee(string name, decimal salary)
{
_name = name;
_salary = salary;
}
/// <summary>
/// 姓名
/// </summary>
private string _name;
/// <summary>
/// 姓名 写函数
/// </summary>
/// <param name="name">姓名</param>
public void setName(string name)
{
_name = name;
}
/// <summary>
/// 姓名读函数
/// </summary>
/// <returns>string</returns>
public string getName()
{
return _name;
}
/// <summary>
/// 工资
/// </summary>
private decimal _salary;
/// <summary>
/// 工资写函数
/// </summary>
/// <param name="salary">工资</param>
public void setSalary(decimal salary)
{
_salary = salary;
}
/// <summary>
/// 工资读函数
/// </summary>
/// <returns>decimal</returns>
public decimal getSalary()
{
return _salary;
}
/// <summary>
/// 输出函数
/// </summary>
public virtual void print()
{
Console.WriteLine(string.Format("我叫:{0},我的工资是:{1}", _name, _salary));
}
}
/// <summary>
/// 佣金雇员类
/// </summary>
class commissionEmployee : Employee
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="name">姓名</param>
/// <param name="sales">销售额</param>
/// <param name="deduct">提成</param>
public commissionEmployee(string name, decimal sales, decimal deduct)
: base(name, 0)
{
this.sales = sales;
this.deduct = deduct;
calMoney();
}
/// <summary>
/// 销售额
/// </summary>
private decimal sales { get; set; }
/// <summary>
/// 提成
/// </summary>
private decimal deduct { get; set; }
/// <summary>
/// 计算工资
/// </summary>
private void calMoney()
{
setSalary(sales * deduct);
}
/// <summary>
/// 输出
/// </summary>
public override void print()
{
Console.WriteLine(string.Format("我叫:{0},我的销售额是:{1},我的提成点是:{2} ,我的工资是:{3},getName(), sales, deduct,getSalary()));
}
}
class Program
{
static void Main(string[] args)
{
Employee Emp = new commissionEmployee("张三",30000M, 0.20M);
Emp.print();
Console.ReadLine();
}
}
2015-07-10 · 知道合伙人软件行家
关注
展开全部
using System;
using System.Management;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
CommissionEmployee emp = new CommissionEmployee("tom", 1000, 2000, 0.2m);
emp.Print();
Console.Read();
}
}
public class Employee
{
public Employee()
{
}
private string empName;
private decimal workPrice = 0m;
/// <summary>
/// 设置员工姓名
/// </summary>
/// <param name="name"></param>
public void SetEmpName(string name)
{
this.empName = name;
}
/// <summary>
/// 获取员工姓名
/// </summary>
/// <returns></returns>
public string GetEmpName()
{
return this.empName;
}
/// <summary>
/// 设置员工工资
/// </summary>
/// <param name="price"></param>
public void SetWorkPrice(decimal price)
{
this.workPrice = price;
}
/// <summary>
/// 获取员工工资
/// </summary>
/// <returns></returns>
public decimal GetWorkPrice()
{
return this.workPrice;
}
/// <summary>
/// 打印员工信息
/// </summary>
public virtual void Print()
{
Console.WriteLine("员工:" + empName + " 工资为:" + workPrice);
}
/// <summary>
/// 构造函数,
/// </summary>
/// <param name="name">姓名</param>
/// <param name="price">工资</param>
public Employee(string name,decimal price)
{
this.empName = name;
this.workPrice = price;
}
}
public class CommissionEmployee:Employee
{
private decimal saleprice;//销售额
private decimal takepricepercent; //提成
public CommissionEmployee()
{
}
/// <summary>
/// 初始化数据成员
/// </summary>
/// <param name="name"></param>
/// <param name="workprice"></param>
/// <param name="salePrice"></param>
/// <param name="takePricePercent"></param>
public CommissionEmployee(string name, decimal workprice, decimal salePrice, decimal takePricePercent):base(name,workprice)
{
this.saleprice = salePrice;
this.takepricepercent = takePricePercent;
}
/// <summary>
/// 计算工资的函数,计算方法为工资=销售额 * 提成
/// </summary>
/// <returns></returns>
public decimal ComputeWages()
{
return saleprice * takepricepercent;
}
/// <summary>
/// 重写Print函数,用于打印:姓名、工资、销售额、提成;
/// </summary>
public override void Print()
{
Console.WriteLine("员工:" + GetEmpName() + "销售额为:" + saleprice + "提成:" + takepricepercent + "工资为:" + ComputeWages());
}
}
}
using System.Management;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
CommissionEmployee emp = new CommissionEmployee("tom", 1000, 2000, 0.2m);
emp.Print();
Console.Read();
}
}
public class Employee
{
public Employee()
{
}
private string empName;
private decimal workPrice = 0m;
/// <summary>
/// 设置员工姓名
/// </summary>
/// <param name="name"></param>
public void SetEmpName(string name)
{
this.empName = name;
}
/// <summary>
/// 获取员工姓名
/// </summary>
/// <returns></returns>
public string GetEmpName()
{
return this.empName;
}
/// <summary>
/// 设置员工工资
/// </summary>
/// <param name="price"></param>
public void SetWorkPrice(decimal price)
{
this.workPrice = price;
}
/// <summary>
/// 获取员工工资
/// </summary>
/// <returns></returns>
public decimal GetWorkPrice()
{
return this.workPrice;
}
/// <summary>
/// 打印员工信息
/// </summary>
public virtual void Print()
{
Console.WriteLine("员工:" + empName + " 工资为:" + workPrice);
}
/// <summary>
/// 构造函数,
/// </summary>
/// <param name="name">姓名</param>
/// <param name="price">工资</param>
public Employee(string name,decimal price)
{
this.empName = name;
this.workPrice = price;
}
}
public class CommissionEmployee:Employee
{
private decimal saleprice;//销售额
private decimal takepricepercent; //提成
public CommissionEmployee()
{
}
/// <summary>
/// 初始化数据成员
/// </summary>
/// <param name="name"></param>
/// <param name="workprice"></param>
/// <param name="salePrice"></param>
/// <param name="takePricePercent"></param>
public CommissionEmployee(string name, decimal workprice, decimal salePrice, decimal takePricePercent):base(name,workprice)
{
this.saleprice = salePrice;
this.takepricepercent = takePricePercent;
}
/// <summary>
/// 计算工资的函数,计算方法为工资=销售额 * 提成
/// </summary>
/// <returns></returns>
public decimal ComputeWages()
{
return saleprice * takepricepercent;
}
/// <summary>
/// 重写Print函数,用于打印:姓名、工资、销售额、提成;
/// </summary>
public override void Print()
{
Console.WriteLine("员工:" + GetEmpName() + "销售额为:" + saleprice + "提成:" + takepricepercent + "工资为:" + ComputeWages());
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
50块钱帮做,+ 解答。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询