wingman007

2015_OOP_Forest_Tree

Apr 15th, 2015
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Forest
  8. {
  9.     class Tree
  10.     {
  11.         #region Fields
  12.         private string type;
  13.         private double diameter;
  14.         private double height;
  15.         private static string color = "green";
  16.         private static int counter = 0;
  17.  
  18.         #endregion
  19.  
  20.         #region Properties
  21.         public string Type
  22.         {
  23.             get { return type; }
  24.             set { type = value; }
  25.         }
  26.  
  27.         public double Diameter
  28.         {
  29.             get { return diameter; }
  30.             set { diameter = value; }
  31.         }
  32.  
  33.         public double Height
  34.         {
  35.             get { return height; }
  36.             set { height = value; }
  37.         }
  38.  
  39.         public static string Color
  40.         {
  41.             get { return color; }
  42.             set { color = value; }
  43.         }
  44.  
  45.         public static int Counter
  46.         {
  47.             get { return counter; }
  48.         }
  49.         #endregion
  50.  
  51.         #region Constructors
  52.         public Tree(string type, double diameter, double height)
  53.         {
  54.             this.type = type;
  55.             this.diameter = diameter;
  56.             this.height = height;
  57.             counter++;
  58.         }
  59.         public Tree(double diameter, string type, double height)
  60.             :this(type, diameter, height)
  61.         { }
  62.  
  63.         public Tree()
  64.             : this("Default", 0, 0)
  65.         { }
  66.         #endregion
  67.  
  68.         public void GetInfo()
  69.         {
  70.             Console.WriteLine("I am a tree. My type is = {0}. diameter = {1}, height = {2}, color = {3}", type, diameter, height, color);
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment