Advertisement
wingman007

2018MIITTreeTreeClassObjectStatic

Apr 19th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 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 Forest1
  8. {
  9.   class Tree
  10.   {
  11.  
  12.     //private string type;
  13.  
  14.     //public string Type
  15.     //{
  16.     //  get { return type; }
  17.     //  set { type = value; }
  18.     //}
  19.  
  20.     //private int counter = 0;
  21.  
  22.     //public int Counter
  23.     //{
  24.     //  get { return counter; }
  25.     //}
  26.  
  27.     public string Type { get; set; }
  28.     public double Diameter { get; set; }
  29.     public double Height { get; set; }
  30.     public static string Color { get; set; }
  31.     public static int Counter { get; private set; }
  32.  
  33.     static Tree()
  34.     {
  35.       Color = "Green";
  36.     }
  37.     public Tree()
  38.       :this("Default", 0.0, 0.0)
  39.     {
  40.  
  41.     }
  42.     public Tree(string type, double diameter, double height)
  43.     {
  44.       Type = type;
  45.       Diameter = diameter;
  46.       Height = height;
  47.       Counter++;
  48.     }
  49.  
  50.     public Tree(double diameter, string type, double height)
  51.       :this(type, diameter, height)
  52.     {
  53.  
  54.     }
  55.  
  56.     public void Introduice()
  57.     {
  58.       Console.WriteLine("Type = {0}, Diameter = {1}, Height = {2}, Color = {3}", Type, Diameter, Height, Color);
  59.     }
  60.   }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement