Advertisement
wingman007

C#_OOP_4a_Human.cs

Apr 14th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 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 App4a
  8. {
  9.     class Human
  10.     {
  11.         private string name;
  12.         private int age;
  13.         private double temp;
  14.         public static int counter = 0;
  15.         public static string nationality = "Bulgarian";
  16.         public const double PI = 3.14;
  17.         public readonly double onlyRead = 2.7;
  18.  
  19.         public string Name
  20.         {
  21.             get { return name; }
  22.             set { name = value; }
  23.         }
  24.  
  25.         public int Age
  26.         {
  27.             get { return age; }
  28.             set { age = value; }
  29.         }
  30.  
  31.         public double Balance
  32.         {
  33.             get { return 2 * 2; }
  34.         }
  35.  
  36.         public Human()
  37.             :this("Default", 0)
  38.         {
  39.             // this.name = "Deafult";
  40.             // this.age = 0;
  41.         }
  42.  
  43.         public Human(string name, int age)
  44.         {
  45.             this.name = name;
  46.             this.age = age;
  47.             counter++;
  48.             onlyRead = 4.5;
  49.         }
  50.  
  51.         public Human(int age, string name)
  52.             : this(name, age)
  53.         {
  54.             // this.name = name;
  55.             // this.age = age;
  56.         }
  57.  
  58.         public void IntroduceYourSelf()
  59.         {
  60.             Console.WriteLine("My name is {0}. I am {1} years old! My balance is {2}. My nationality is {3}", name, age, Balance, nationality);
  61.         }
  62.  
  63.         public void IntroduceYourSelf(string verbous)
  64.         {
  65.             IntroduceYourSelf();
  66.             Console.WriteLine("I should be more verbous!");
  67.             // Console.WriteLine("My name is {0} and the value is contained in a field. I am {1} years old! My balance is {2}", name, age, Balance);
  68.         }
  69.  
  70.         /*
  71.         public string GetName()
  72.         {
  73.             return name;
  74.         }
  75.  
  76.         public void SetName(string name)
  77.         {
  78.             this.name = name;
  79.         }
  80.  
  81.         public int GetAge()
  82.         {
  83.             return age;
  84.         }
  85.  
  86.         public void SetAge(int age)
  87.         {
  88.             this.age = age;
  89.         }
  90.         */
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement