Advertisement
wingman007

C#_OOP_3a_Human.cs

Apr 15th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.60 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 App3a
  8. {
  9.     class Human
  10.     {
  11.         private string name;
  12.         private int age;
  13.         private double temp;
  14.         public static int counter = 0;
  15.         private static string nationality = "Bulgarian";
  16.         private string[] friends = new string[5];
  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 * 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.         }
  61.  
  62.         public Human(int age, string name, params string[] friends)
  63.             : this(name, age)
  64.         {
  65.             // this.name = name;
  66.             // this.age = age;
  67.             int i = 0;
  68.             foreach (string friend in friends)
  69.             {
  70.                 this.friends[i] = friend;
  71.             }
  72.         }
  73.  
  74.         public void IntroduceYourSelf()
  75.         {
  76.             Console.WriteLine("My name is {0}. I am {1} years old! My Balance is {2}. I am {3}.", name, age, Balance, nationality);
  77.         }
  78.  
  79.         public void IntroduceYourSelf(string verbous)
  80.         {
  81.             IntroduceYourSelf();
  82.             Console.WriteLine("Being more Verbous");
  83.         }
  84.  
  85.         public string GetFriend(int index)
  86.         {
  87.             return this.friends[index];
  88.         }
  89.  
  90.         public static double CalculateNationalIncome()
  91.         {
  92.             return counter * 10000;
  93.         }
  94.  
  95. /*
  96.         public string GetName()
  97.         {
  98.             return name;
  99.         }
  100.  
  101.         public void SetName(string name)
  102.         {
  103.             this.name = name;
  104.         }
  105.  
  106.         public int GetAge()
  107.         {
  108.             return age;
  109.         }
  110.  
  111.         public void SetAge(int age)
  112.         {
  113.             this.age = age;
  114.         }
  115. */
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement