Boundary, Entity, Control class and ICONIX process and Robustness Diagrams有很多文字。但是没有实际的代码示例,我们如何在代码中实现控制类?这是我的代码示例,我想检测此代码中的控件类在哪里?
类:
Program_Boundary : 边界类
人:实体
人:实体(因为它有 CRUD 操作)
控制类在哪里?此示例是否有控制类:
class Program_Boundary // BoundaryClass
{
static void Main(string[] args)
{
People people = new People();
Person person;
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Enter name:");
string name = Console.ReadLine();
Console.WriteLine("Enter family:");
string family = Console.ReadLine();
person = new Person(name, family);
people.Add(person);
}
}
}
class People //Entity Class
{
List<Person> person_list = new List<Person>();
public People()
{
}
public void Add(Person person)
{
person_list.Add(person);
}
public void Delete(string name, string family)
{
for (int i = 0; i < person_list.Count; i++)
if (person_list[i].name == name && person_list[i].family == family)
person_list.Remove(person_list[i]);
}
public void Update(string name, string family, string new_name, string new_family)
{
for (int i = 0; i < person_list.Count; i++)
if (person_list[i].name == name && person_list[i].family == family)
{
person_list[i].name = new_name;
person_list[i].family = new_family;
}
}
}
class Person //Entity Class
{
private string _name;
private string _family;
public Person(string n,string f)
{
_name = n;
_family = f;
}
public string name { get { return _name; } set { _name = value; } }
public string family { get { return _family; } set { _family = value; } }
}