求C#的测试类(急用)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
enum Sexkind { Male, Female }
class Human
{
private string no;
public string No
{
get { return no; }
set
{
int y = int.Parse(no.Substring(0, 4));
if (no == null || no.Length != 12)
throw new Exception("长度不到十二位");
else if
(y > DateTime.Now.Year || y < DateTime.Now.Year - 100)
throw new Exception("年份错误");
else
no = value;
}
}
public string Name { set; get; }
public Sexkind Sex { set; get; }
public int count { set; get; }
public int Year
{
get { return int.Parse(no.Substring(0, 4)); }
}
public string Info
{
get { return No + "\t" + Name + "\t" + Sex; }
}
public Human()
{
count++;
}
public Human(string no, string name, Sexkind sex)
{
count++;
No = no;
Name = name;
Sex = sex;
}
public void Show()
{
Console.WriteLine(Info);
}
public void SayHello()
{
Console.WriteLine("Hello, human!");
}
public delegate void State(object sender, string message);
public event State OnIdle;
public event State OnWork;
static void Main(string[] args)
{
Human hu = new Human("201902211122", "哇哈哈", Sexkind.Male);
hu.Show();
hu.SayHello();
}
}
}
}