Advertisement
wingman007

2018OOPPerson

May 2nd, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 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 WorldITMOMIM
  8. {
  9.   class Person : IIntroducable // : Object
  10.   {
  11.     protected string name;
  12.     protected int age;
  13.  
  14.     public string Name
  15.     {
  16.       get { return name; }
  17.       set { name = value; }
  18.     }
  19.  
  20.     public int Age
  21.     {
  22.       get { return age; }
  23.       set { age = value; }
  24.         //if (value > 120 || value < 0)
  25.         //{
  26.         //  value = 0;
  27.         //}
  28.         //age = value; }
  29.     }
  30.  
  31.     public Person()
  32.       : this("Default", 0)
  33.     {
  34.       //this.name = "Default";
  35.       //this.age = 0;
  36.     }
  37.  
  38.     // working horse
  39.     public Person(string name, int age)
  40.     {
  41.       this.name = name;
  42.       this.age = age;
  43.     }
  44.  
  45.  
  46.     //public string GetName()
  47.     //{
  48.     //  return name;
  49.     //}
  50.  
  51.     //public void SetName(string name)
  52.     //{
  53.     //  this.name = name;
  54.     //}
  55.  
  56.     //public void SetAge(int age)
  57.     //{
  58.     //  if (age > 120 ||age < 0)
  59.     //  {
  60.     //    age = 0;
  61.     //  }
  62.  
  63.     //  this.age = age;
  64.     //}
  65.  
  66.     public virtual void IntroduceYourSelf()
  67.     {
  68.       Console.WriteLine("My name is {0}. I am {1} years old.", name, age);
  69.     }
  70.  
  71.   }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement