📄 person.cs
字号:
// Fig. 10.16: Person.cs
// Class Person has a birthday.
using System;
public class Person : IAge
{
private string firstName;
private string lastName;
private int yearBorn;
// constructor
public Person( string firstNameValue, string lastNameValue,
int yearBornValue )
{
firstName = firstNameValue;
lastName = lastNameValue;
if ( yearBornValue > 0 && yearBornValue <= DateTime.Now.Year )
yearBorn = yearBornValue;
else
yearBorn = DateTime.Now.Year;
}
// property Age implementation of interface IAge
public int Age
{
get
{
return DateTime.Now.Year - yearBorn;
}
}
// property Name implementation of interface IAge
public string Name
{
get
{
return firstName + " " + lastName;
}
}
} // end class Person
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -