Advertisement
wingman007

OOP_2015_4Principles_Person

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