Advertisement
wingman007

C#_OOP_2a_Human.cs

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