Advertisement
wingman007

C#_OOP_1b_Human.cs

Apr 17th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.89 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 App1b
  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] { "Default", "Default", "Default", "Default", "Default"};
  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.         static Human()
  39.         {
  40.             onlyRead = 2.71;
  41.         }
  42.  
  43.         public Human()
  44.             : this("Default", 0)
  45.         {
  46.            // name = "Default";
  47.            // age = 0;
  48.         }
  49.  
  50.         public Human(string name, int age)
  51.         {
  52.             this.name = name;
  53.             this.age = age;
  54.             counter++;
  55.             // this.onlyRead = 2.7;
  56.         }
  57.  
  58.         public Human(int age, string name, params string[] friends)
  59.             : this(name, age)
  60.         {
  61.             // this.name = name;
  62.             // this.age = age;
  63.              int i = 0;
  64.             foreach (string friend in friends)
  65.             {
  66.                 this.friends[i] = friend;
  67.                 i++;
  68.             }
  69.         }
  70.  
  71.         public double Balance
  72.         {
  73.             get { return name.Length * 2 * 2; }
  74.         }
  75.  
  76.         public void IntroduceYourSelf()
  77.         {
  78.             Console.WriteLine("My name is {0}. I am {1} years old. And My Banace 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 told to be {0}", verbous);
  85.             // Console.WriteLine("My name is {0} And it is saved in a field. I am {1} years old. And My Banace is {2}. And I am told to be {3}", name, age, Balance, verbous);
  86.         }
  87.  
  88.         public string GetFriend(int index)
  89.         {
  90.             return this.friends[index];
  91.         }
  92.  
  93.         public static double CalculateNationalIncome()
  94.         {
  95.             return counter * 10000;
  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