创建一个Employee类。作为数据成员包含的项目为 雇员编号,姓名,出租日期,职位描述,部门和 月薪。该课程通常用于显示所有员工的英文字母 列表。包括适当的构造函数和 属性。重写ToString()方法返回所有成员的数据 。创建第二个类来测试你的Employee类。如何测试简单的课程?
我已经用适当的变量,属性和构造函数创建了一个Employee类,但是在通过第二个类“测试”它时遇到了问题。我写的代码运行没有错误,但没有显示任何东西(大概是测试的目标)。我在哪里在调用部分出错?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeProgram
{
public class EmployeeProgram
{
private int employeeNumber;
private string name;
private string hiredate;
private int monthlySalary;
private string description;
private string department;
public employee(int employeeNumber, string name, string dateOfHire, int monthlySalary, string description, string department)
{
this.employeeNumber = 456;
this.name = "Joyce";
this.hiredate = "12/15/14";
this.monthlySalary = 3200;
this.description = "Manager";
this.department = "Accounting";
}
public int EmployeeNumber
{
get
{
return employeeNumber;
}
set
{
employeeNumber = value;
}
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string Hiredate
{
get
{
return hiredate;
}
set
{
hiredate = value;
}
}
public int MonthlySalary
{
get
{
return monthlySalary;
}
set
{
monthlySalary = value;
}
}
public string Department
{
get
{
return department;
}
set
{
department = value;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
public override string ToString()
{
return "Employee ID: " + employeeNumber +
"Employee Name: " + name +
"Employee Hire Date: " + hiredate +
"Employee Monthly Salary: " + monthlySalary +
"Employee Description: " + description +
"Employee Department: " + department;
}
public void Print()
{
Console.WriteLine(this.ToString());
}
}
}
这不是C++,请不要标记无关的编程语言。此外,不知道任何C#,这看起来像它需要[mcve],而不是这个代码块。 –
向我们展示您的主程序 – JSON