【发布时间】:2020-03-30 17:00:19
【问题描述】:
我在没有应用任何设计模式的情况下编写了下面的代码,这段代码有什么问题。
class Employee {
public int EmployeeID
{ get; set; }
public int YearOExperience
{ get; set; }
public int Salary
{ get; set; }
public string EmploeyeeType
{ get; set; }
}
interface IEmployee {
List<Employee> getInformation(int id, int exp, int sal);
}
class EmployeeData1 {
public List<Employee> GetData(int id,int exp , int sal)
{
List<Employee> empInfo = new List<Employee> {
new Employee { EmploeyeeType = "P", EmployeeID = 1, Salary = 20000, YearOExperience= 2 },
new Employee { EmploeyeeType = "P", EmployeeID = 2, Salary = 20000, YearOExperience= 2 },
new Employee { EmploeyeeType = "C", EmployeeID = 3, Salary = 20000, YearOExperience= 2 }
};
return empInfo;
}
}
static void Main(string[] args) {EmployeeData1 emp = new EmployeeData1();
emp.getInformation(1, 2, 2000);
};
}
【问题讨论】:
-
您要解决什么问题?这会做你不想要的事情,还是没有做你想做的事情?
-
这段代码遇到了什么问题?您创建的界面不能在代码中的任何地方使用。这是我注意到的一个问题。
-
我想用设计模式,你可以吗
标签: c# oop design-patterns solid-principles