Advertisement
wingman007

OOP_2015_Person

Mar 17th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 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 Person1a
  8. {
  9.     class Person
  10.     {
  11.         private string name;
  12.         private int age;
  13. //        private string jfgasga87264264ad;
  14.         private double temp;
  15.         public static int counter = 0;
  16.         public static string nationality = "Bulgarian";
  17.        
  18.     #region Properties
  19.     public string Name
  20.         {
  21.             get { return name; }
  22.             set { name = value; }
  23.         }
  24.  
  25. //        public string Name { get; set; }
  26.  
  27.         public int Age
  28.         {
  29.             get { return age; }
  30.             set { age = value; }
  31.         }
  32.  
  33.         public double Balance
  34.         {
  35.             get { return 2 * age; }
  36.         }
  37.  
  38.     #endregion
  39.  
  40.         // working horse
  41.         public Person(string name, int age)
  42.         {
  43.             this.name = name;
  44.             this.age = age;
  45.             counter++;
  46.         }
  47.  
  48.         public Person()
  49.             : this("Default", 0)
  50.         {
  51.             // this.name = "Default";
  52.             // this.age = 0;
  53.         }
  54.  
  55.         public Person(int age, string name)
  56.             : this(name, age)
  57.         { }
  58.  
  59.         /*
  60.         public string GetName()
  61.         {
  62.             return name;
  63.         }
  64.  
  65.         public void SetName(string name)
  66.         {
  67.             this.name = name;
  68.         }
  69.  
  70.         public int GetAge()
  71.         {
  72.             return age;
  73.         }
  74.  
  75.         public void SetAge(int age)
  76.         {
  77.             this.age = age;
  78.         }
  79.         */
  80.  
  81.         public void IntroduceYourSelf()
  82.         {
  83.             Console.WriteLine("My name is {0}. I am {1} years old! My nationality is {2}", name, age, nationality);
  84.         }
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement