Advertisement
wingman007

C#_OOP_Inheritance_Human.cs

May 1st, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.64 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 App1
  8. {
  9.     class Human
  10.     {
  11.         protected string name;
  12.         protected int age;
  13.         private double temp;
  14.         private string[] friends = new string[5] { "Default", "Default", "Default", "Default", "Default" };
  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.6;
  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; }
  41.         }
  42.  
  43.         static Human()
  44.         {
  45.             onlyRead = 2.7;
  46.         }
  47.  
  48.         public Human()
  49.             : this("Default", 0)
  50.         { }
  51.  
  52.         public Human(string name, int age)
  53.         {
  54.             this.name = name;
  55.             this.age = age;
  56.             counter++;
  57.             // onlyRead = 2.7;
  58.         }
  59.  
  60.         public Human(int age, string name, params string[] friends)
  61.             : this(name, age)
  62.         {
  63.            // this.name = name;
  64.            // this.age = age;
  65.             int i = 0;
  66.             foreach (string friend in friends) {
  67.                 this.friends[i] = friend;
  68.                 i++;
  69.             }
  70.         }
  71.  
  72.         public virtual void IntroduceYoutSelf()
  73.         {
  74.             Console.WriteLine("My name is {0}. I am {1} yers old. And my Balnace is {2}. My nationality is {3}", name, age, Balance, nationality);
  75.         }
  76.  
  77.         public void IntroduceYoutSelf(string verbous)
  78.         {
  79.             IntroduceYoutSelf();
  80.             Console.WriteLine("I have been told {0}", verbous);
  81.         }
  82.  
  83.         public string GetFriend(int index)
  84.         {
  85.             return friends[index];
  86.         }
  87.  
  88.         public static double CalculateNationalIncome()
  89.         {
  90.             return counter * 10000;
  91.         }
  92. /*
  93.         public string GetName()
  94.         {
  95.             return name;
  96.         }
  97.  
  98.         public void SetName(string name)
  99.         {
  100.             this.name = name;
  101.         }
  102.  
  103.         public int GetAge()
  104.         {
  105.             return age;
  106.         }
  107.  
  108.         public void SetAge(int age)
  109.         {
  110.             this.age = age;
  111.         }
  112. */
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement