tree.cs
来自「C#语言高级编成,我多年总结的经验,肯定能让你学到很多」· CS 代码 · 共 42 行
CS
42 行
// Fig. 7.17: Tree.cs
// Class Tree contains number of rings corresponding to its age.
using System;
public class Tree : IAge
{
private int rings; // number of rings in tree trunk
// constructor
public Tree( int yearPlanted )
{
// count number of rings in Tree
rings = DateTime.Now.Year - yearPlanted;
}
// increment ring
public void AddRing()
{
rings++;
}
// property Age implementation of interface IAge
public int Age
{
get
{
return rings;
}
}
// property Name implementation of interface IAge
public string Name
{
get
{
return "Tree";
}
}
} // end class Tree
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?