Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 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 ConsoleApp7
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Doctor test = new Doctor();
  14.             Doctor doctor1 = new Doctor()
  15.             {
  16.                 Name = "John",
  17.                 Age = 30,
  18.                 Expirience = 4
  19.             };
  20.             Doctor doctor2 = new Doctor()
  21.             {
  22.                 Name = "Jack",
  23.                 Age = 28,
  24.                 Expirience = 7
  25.             };
  26.             test.CanPerformOperation(doctor1, delegate () {
  27.                 return doctor1.Expirience > 5 && doctor1.Age < 40;
  28.             });
  29.             test.CanPerformOperation(doctor2, delegate () {
  30.                 return doctor2.Expirience > 5 && doctor2.Age < 40;
  31.             });
  32.  
  33.             Console.ReadLine();
  34.  
  35.         }
  36.     }
  37.  
  38.     public delegate bool CanPromotedDelegate();
  39.  
  40.    
  41.  
  42.  
  43.  
  44.     //5 diferent ways of calculating for CanPerformOperation
  45.     // 1. Expirience > 5 AND age < 40
  46.     // 2. Expirience > 6 AND age < 45
  47.     // 3. Expirience > 7 AND age < 46
  48.     // 4. Expirience > 8 AND age < 47
  49.     // 5. Expirience > 9 AND age < 48
  50.     public class Doctor
  51.     {
  52.         public int Expirience { get; set; }
  53.         public int Age { get; set; }
  54.         public string Name { get; set; }
  55.  
  56.         public void CanPerformOperation(Doctor d, CanPromotedDelegate del)
  57.         {
  58.             if (del() == true)
  59.             {
  60.                 Console.WriteLine($"{d.Name} can perform operation");
  61.             }
  62.             else
  63.             {
  64.                 Console.WriteLine($"{d.Name} cannot perform operation");
  65.             }
  66.         }
  67.     }
  68.  
  69.  
  70.     //5 diferent ways of calculating for CanGoUnderOperation
  71.     // 1. age < 40
  72.     // 1. age < 45
  73.     // 1. age < 46
  74.     // 1. age < 47
  75.     // 1. age < 48
  76.     public class Patient
  77.     {
  78.         public int Age { get; set; }
  79.  
  80.         public bool CanGoUnderOperation()
  81.         {
  82.             return true;
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement