⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tree.cs

📁 this is a good book for the visual c#
💻 CS
字号:
// Fig. 10.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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -