Advertisement
wingman007

C#_OOP_Features_Program

Jun 5th, 2014
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.11 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 Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine(Human.PI);
  14.             // int counter = 0;
  15.            
  16.             Human person1 = new Human("Stoyan", 50, Human.BrainSize.Normal);
  17.             Console.WriteLine("Only for read = {0}", Human.onlyRead);
  18.             // counter++;
  19.  
  20.             person1.onIntroduceYourSelf = delegate(string message) {
  21.                 Console.WriteLine("This guy trys to introduce him self {0} again hahaha", message);
  22.             };
  23.  
  24.             person1.onIntroduceYourSelf = delegate(string message)
  25.             {
  26.                 Console.WriteLine("Nasheto momche pak se predstawi {0}", message);
  27.             };
  28.  
  29.             Human person2 = new Human(20, "Ivan", "Petko", "Niki");
  30.             // counter++;
  31.  
  32.             Human person3 = new Human();
  33.             // counter++;
  34.  
  35.             // Console.WriteLine("My name is {0}. I am {1} years old", person1.Name, person1.Age);
  36.             // Console.WriteLine("My name is {0}. I am {1} years old", person2.Name, person2.Age);
  37.  
  38.             Human.Nationality = "German";
  39.  
  40.             // Human.Brain brain = new Human.Brain();
  41.  
  42.             person1.IntroduceYourSelf("dummy");
  43.             person2.IntroduceYourSelf();
  44.             Console.WriteLine("And my best friend is {0}", person2.GetFriend(0));
  45.             person3.IntroduceYourSelf();
  46.  
  47.             IncreasePopulation();
  48.             IncreasePopulation();
  49.  
  50.             Student student1 = new Student();
  51.             // student1.Name = "Student1";
  52.             // student1.Age = 18;
  53.             Athelete athlete1 = new Athelete("Krisko", 20, "box" );
  54.  
  55.             Executor exec1 = new Executor(athlete1);
  56.             exec1.MakeHimSpeak();
  57.  
  58.  
  59.             // Athelete athlete1 = new Athelete();
  60.             // athlete1.IntroduceYourSelf();
  61.             // athlete1.ShowFNumber();
  62.             // athlete1.ShowSport();
  63.  
  64.  
  65.             Console.WriteLine(Days.Friday);
  66.             Console.WriteLine((int)Days.Friday);
  67.             Console.WriteLine(Days.Friday is Days);
  68.  
  69.             Manager<Student> manager = new Manager<Student>();
  70.             // manager.AddStudent(student1);
  71.             // manager.AddStudent(student1);
  72.             // manager.RemoveStudent();
  73.             manager.AddEntity(student1);
  74.             manager.AddEntity(student1);
  75.             manager.RemoveEntity();
  76.             Console.WriteLine("I am managing {0} students", manager.GetNumberOfEntities());
  77.  
  78.             var autoPerson = new AutoHuman { Name = "Stooyan", Age= 32 };
  79.             // autoPerson.Name = "Stoyan";
  80.             // autoPerson.Age = 32;
  81.  
  82.             // List<AutoHuman> people = new List<AutoHuman>();
  83.             // people.Add(autoPerson);
  84.             List<AutoHuman> people = new List<AutoHuman>() {
  85.                 new AutoHuman { Name = "Scott", Age = 43 }, // read only properties
  86.                 new AutoHuman { Name = "Susan", Age = 15 },
  87.                 new AutoHuman { Name = "Ivan", Age = 16 },
  88.                 new AutoHuman { Name = "Peter", Age = 16 }
  89.             };
  90.  
  91.             foreach (AutoHuman person in people)
  92.             {
  93.                 Console.WriteLine(person.Name);
  94.             }
  95.  
  96.             var anonymousPerson = new { Name = "Nikolay", Age = 22, Sex = "male" };
  97.             var anonymousArray = new[] { new { Name = "Stoyan", Age = 51 }, new { Name = "Stoyan", Age = 34 } }; // new { Type = "Product1", Price = 34.56}
  98.  
  99.             DelegateTest.Test();
  100.             // DelegateTest delagateTest = new DelegateTest();
  101.             // delagateTest.Test();
  102.  
  103.             string email = "dadsa@fsdf.com"; //
  104.             Console.WriteLine("This string is a valid e-mail = {0}", email.IsValidEmailAddress());
  105.  
  106.             var result = from p in people
  107.                          where p.Name.StartsWith("S")
  108.                          orderby p.Age descending
  109.                          select new { p.Name, p.Age, sex = 2 };
  110.  
  111.             foreach (var personI in result) {
  112.                 Console.WriteLine("Found {0} {1}", personI.Name, personI.Age);
  113.             }
  114.  
  115.             Console.WriteLine("My population is {0}", Human.counter);
  116.  
  117.             Console.WriteLine("The National Income is {0}", Human.CalculateNationalIncome());
  118.  
  119.             Console.WriteLine("Hello World!");
  120.             /*
  121.             string input = Console.ReadLine();
  122.             Console.WriteLine(input);
  123.             try
  124.             {
  125.                 int validated = Int16.Parse(input);
  126.                 Console.WriteLine("Sled parsing chisloto e {0}", validated);
  127.             }
  128.             catch (Exception e)
  129.             {
  130.                 Console.WriteLine("Error");
  131.             }
  132.            */
  133.             Console.Read();
  134.         }
  135.  
  136.         public static void IncreasePopulation()
  137.         {
  138.             Human person1 = new Human("Pesho", 15, Human.BrainSize.Large);
  139.         }
  140.  
  141.         public enum Days {
  142.             Monday, Tuesday, Wednesday, Thursday, Friday = 400, Saturday, Sunday
  143.         }
  144.     }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement