wingman007

2015_OOP_World4_Static_Person

Apr 21st, 2015
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 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 World4
  8. {
  9.     class Person
  10.     {
  11.         private string name;
  12.         // private string sagdfghsa3656_;
  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.         // auto property
  32.         // public string Name { get; set; }
  33.  
  34.         public string Name
  35.         {
  36.             get { return name; }
  37.             set { name = value; }
  38.         }
  39.  
  40.         public int Age
  41.         {
  42.             get { return age; }
  43.             set { age = value; }
  44.         }
  45.  
  46.         public double Balance
  47.         {
  48.             get { return 2 * age * temp; }
  49.         }
  50.  
  51.         static Person()
  52.         {
  53.             onlyRead = counter * 2.71;
  54.         }
  55.  
  56.         // Working Horse
  57.         public Person(string name, int age = 0)
  58.         {
  59.             this.name = name;
  60.             this.age = age;
  61.             counter++;
  62.             // onlyRead = age * 2.71; // not possible
  63.         }
  64.  
  65.         public Person()
  66.             : this("Default", 0)
  67.         {
  68.             // this.name = "Default";
  69.             // this.age = 0;
  70.         }
  71.  
  72.         public Person(int age, string name, params string[] friends)
  73.             : this(name, age)
  74.         {
  75.             // this.name = name;
  76.             // this.age = age;
  77.         }
  78.  
  79.         public void IntroduceYourSelf()
  80.         {
  81.             Console.WriteLine("My name is {0}. I am {1} years old! And my balance is {2}. I am {3}",
  82.                 name, age, Balance, nationality);            
  83.         }
  84.  
  85.         public static double CalculateNationalIncome()
  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.         public void SetAge(int age)
  106.         {
  107.             this.age = age;
  108.         }
  109.         */
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment