wingman007

2015_OOP_World3_Static_Person

Apr 21st, 2015
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.45 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 World3
  8. {
  9.     class Person
  10.     {
  11.         // private string asdgjhsa23432dasdgakjgh;
  12.         private string name;
  13.         private int age;
  14.         private double temp = 0.23;
  15.         private static int counter = 0;
  16.         private static string nationality = "Bulgarian";
  17.         public const double PI = 3.14;
  18.         public static readonly double onlyRead = 5.4;
  19.  
  20.         public static int Counter
  21.         {
  22.             get { return counter; }
  23.         }
  24.  
  25.         public static string Nationality
  26.         {
  27.             get { return nationality; }
  28.             set { nationality = value; }
  29.         }
  30.  
  31.  
  32.         // public string Name { get; set; }
  33.         public string Name
  34.         {
  35.             get { return name; }
  36.             set { name = value; }
  37.         }
  38.  
  39.         public int Age
  40.         {
  41.             get { return age; }
  42.             set { age = value; }
  43.         }
  44.  
  45.         public double Balance
  46.         {
  47.             get { return 2 * age * temp; }
  48.         }
  49.  
  50.         static Person()
  51.         {
  52.             onlyRead = counter * 2.71;
  53.         }
  54.  
  55.         // Working Horse
  56.         public Person(string name, int age = 0)
  57.         {
  58.             this.name = name;
  59.             this.age = age;
  60.             counter++;
  61.             // onlyRead = age * 2.71; // not possible
  62.         }
  63.  
  64.         public Person()
  65.             : this("Deafult", 0)
  66.         {
  67.             // this.name = "Default";
  68.             // this.age = 0;
  69.         }
  70.  
  71.         public Person(int age, string name, params string[] friend )
  72.             : this(name, age)
  73.         {
  74.             // this.name = name;
  75.             // this.age = age;
  76.         }
  77.  
  78.  
  79.         public void IntroduceYourSelf()
  80.         {
  81.             Console.WriteLine("My name is {0}. I am {1} years old. My balce is {2}. I am {3}",
  82.                 name, age, Balance, nationality);            
  83.         }
  84.  
  85.         public static double CountNationaIncome()
  86.         {
  87.             return counter * 10000;
  88.         }
  89.  
  90. /*
  91.         public string GetName()
  92.         {
  93.             return name;
  94.         }
  95.  
  96.         public void SetName(string name)
  97.         {
  98.             this.name = name;
  99.         }
  100.  
  101.         public int GetAge()
  102.         {
  103.             return age;
  104.         }
  105.  
  106.         public void SetAge(int age)
  107.         {
  108.             this.age = age;
  109.         }
  110. */
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment