Advertisement
wingman007

2018TreeTreeClassObjectStatic

Apr 18th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 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.     //private string type;
  12.  
  13.     //public string Type
  14.     //{
  15.     //  get { return type; }
  16.     //  set { type = value; }
  17.     //}
  18.     //private static int counter = 0;
  19.     //public static int Counter {
  20.     //  get { return counter; }
  21.     //}
  22.  
  23.     public static int Counter { get; private set; }
  24.  
  25.     public string Type { get; set; }
  26.     public double Diameter { get; set; }
  27.     public double Height { get; set; }
  28.     public static string Color { get; set; }
  29.  
  30.     static Tree()
  31.     {
  32.       Color = "Green";
  33.     }
  34.  
  35.     public Tree(string type, double diameter, double height)
  36.     {
  37.       Type = type;
  38.       Diameter = diameter;
  39.       Height = height;
  40.       Counter++;
  41.     }
  42.  
  43.     public void Introduce()
  44.     {
  45.       Console.WriteLine("Type = {0}, Diameter = {1}, Height = {2}, Color = {3}", Type, Diameter, Height, Color);
  46.     }
  47.   }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement