wingman007

2015_OOP_Features_Program

May 27th, 2015
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.34 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 World1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Days days = Days.Fr;
  14.             Console.WriteLine("My PI = {0}", Person.PI);
  15.             Console.WriteLine("Only for read = {0}", Person.onlyRead);
  16.  
  17.             // int counter = 0;
  18.             Person person1 = new Person("Stoyan", 51);
  19.             // person1.Name = "Stoyan";
  20.             // person1.Age = 51;
  21.             // counter++;
  22.  
  23.             Person person2 = new Person(20, "Mario", "Bobi", "Kristian", "Stoyan", "Anton");
  24.             // person2.Name = "Mario";
  25.             // person2.Age = 20;
  26.             // counter++;
  27.  
  28.             Person person3 = new Person();
  29.             // counter++;
  30.  
  31.             IncreasPopulation();
  32.  
  33.             person1.IntroduceYourSelf();
  34.             person2.IntroduceYourSelf();
  35.             person3.IntroduceYourSelf();
  36.  
  37.             Person.Nationality = "German";
  38.  
  39.             person1.IntroduceYourSelf();
  40.             person2.IntroduceYourSelf();
  41.             person3.IntroduceYourSelf();
  42.  
  43.             // Console.WriteLine("The population of my kingdom is {0}", counter);
  44.  
  45.             Console.WriteLine("The population of my kingdom is {0}", Person.Counter);
  46.  
  47.             Console.WriteLine("National Income = {0}", Person.GetNationalIncome());
  48.  
  49.             Person student1 = new Student("Kircho", 25, "4314324234");
  50.             student1.IntroduceYourSelf();
  51.  
  52.             Student student2 = new Student();
  53.  
  54.             Athlete athlete1 = new Athlete("Krisi", 25, "box");
  55.             athlete1.IntroduceYourSelf();
  56.  
  57.             Executor exec = new Executor(student1);
  58.             exec.MakeHimSpeak();
  59.  
  60.             Console.WriteLine(student1); // .ToString()
  61.  
  62.  
  63.             /*
  64.             Console.WriteLine("My name is {0}! I am {1} years old! My balance is {2}",
  65.                 person1.Name, person1.Age, person1.Balance);
  66.  
  67.             Console.WriteLine("My name is {0}! I am {1} years old!",
  68.                 person2.Name, person2.Age);
  69.  
  70.             Console.WriteLine("My name is {0}! I am {1} years old!",
  71.                 person3.Name, person3.Age);
  72.             */
  73.  
  74.             Console.WriteLine(Days.Fr);
  75.             Console.WriteLine((int)Days.Fr);
  76.             Console.WriteLine(Days.Fr is Days);
  77.  
  78.             Manager<Student> man1 = new Manager<Student>();
  79.             man1.AddEntity(student2);
  80.             man1.AddEntity(student2);
  81.             man1.AddEntity(student2);
  82.             man1.RemoveEntity();
  83.             man1.RemoveEntity();
  84.             Console.WriteLine(man1.GetNumberOfEntities());
  85.  
  86.             Console.WriteLine("=========================================");
  87.  
  88.             var autoPerson1 = new AutoPerson { Name = "Stoyan", Age = 51};
  89.             // autoPerson1.Name = "Stoyan";
  90.             // autoPerson1.Age = 51;
  91.  
  92.             Console.WriteLine("Atoperson Name = {0} Age = {1}",
  93.                 autoPerson1.Name, autoPerson1.Age);
  94.  
  95.             var name = "Stoyan";
  96.             var age = 51;
  97.  
  98.             Console.WriteLine("Name = {0} Age = {1}", name, age);
  99.  
  100.             // List<AutoPerson> people = new List<AutoPerson>();
  101.             // people.Add(autoPerson1);
  102.             // AutoPerson autoperson2 = new AutoPerson();
  103.             // people.Add(autoPerson2);
  104.  
  105.             List<AutoPerson> people = new List<AutoPerson>() {
  106.                 new AutoPerson { Name = "Scott", Age = 43 }, // read only properties
  107.                 new AutoPerson { Name = "Susan", Age = 15 },
  108.                 new AutoPerson { Name = "Ivan", Age = 16 },
  109.                 new AutoPerson { Name = "Peter", Age = 16 }
  110.             };
  111.  
  112.             foreach (AutoPerson person in people)
  113.             {
  114.                 Console.WriteLine(person.Name);
  115.             }
  116.  
  117.             var anonymousPerson = new { Name = "Marion", Age = 19, Gender = "female" };
  118.             var anonymousArray = new[] { new { Name = "Stoyan", Age = 51 }, new { Name = "Stoyan", Age = 34 } }; // new { Type = "Product1", Price = 34.56}
  119.  
  120.             // anonymousPerson.Name = "NotPossible Only for reading";
  121.            
  122.             DelegateTest delegateTest = new DelegateTest();
  123.             DelegateTest.Test();
  124.  
  125.             person1.onIntroduce = OnIntroduce;
  126.             // person1.onIntroduce = OnIntroduce;
  127.             person1.IntroduceYourSelf();
  128.  
  129.             string myEmail = "[email protected]";
  130.             Console.WriteLine("This is a valid e-mail {0}", myEmail.IsValidEmailAddress());
  131.  
  132.             // IEnumerable
  133.             var result = from p in people
  134.                          where p.Name.StartsWith("S")
  135.                          orderby p.Age descending
  136.                          select new { p.Name, p.Age, sex = 2 };
  137.  
  138.             foreach (var personI in result)
  139.             {
  140.                 Console.WriteLine("Found {0} {1}", personI.Name, personI.Age);
  141.             }
  142.  
  143.         }
  144.  
  145.         private static void IncreasPopulation()
  146.         {
  147.             Person person1 = new Person("Petko", 15);
  148.         }
  149.         public enum Days
  150.         {
  151.             Mo, Tu, We, Th, Fr = 1400, Sa, Su
  152.         }
  153.  
  154.         private static void OnIntroduce(string message)
  155.         {
  156.             Console.WriteLine("===== Hahahah This guy {0} again introduced him self", message);
  157.         }
  158.  
  159.     }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment