Advertisement
wingman007

C#_OOP_2b_Human.cs

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