Advertisement
Guest User

MAD 1

a guest
Sep 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.35 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 MAD___CV1
  8. {
  9.     class Program
  10.     {
  11.         private static int allIterationsCount = 0;
  12.  
  13.         //outlook == sunny && humidity == high && play == no
  14.         private static int firstRuleFounds = 0;
  15.  
  16.         //outlook == rainy && windy == true && play == no
  17.         private static int secondRuleFounds = 0;
  18.  
  19.         //outlook == overcast && play == yes
  20.         private static int thirdRuleFounds = 0;
  21.  
  22.         //humidity == normal && play == yes
  23.         private static int fourthRuleFounds = 0;
  24.  
  25.         //none of above play == yes
  26.         private static int fifthRuleFounds = 0;
  27.  
  28.         enum OutlookOptions
  29.         {
  30.             sunny,
  31.             overcast,
  32.             rainy,
  33.             none
  34.         }
  35.  
  36.         enum TemperatureOptions
  37.         {
  38.             hot,
  39.             mild,
  40.             cool,
  41.             none
  42.         }
  43.  
  44.         enum HumidityOptions
  45.         {
  46.             high,
  47.             normal,
  48.             none
  49.         }
  50.  
  51.         enum WindyOptions
  52.         {
  53.             TRUE,
  54.             FALSE,
  55.             none
  56.         }
  57.  
  58.         enum PlayOptions
  59.         {
  60.             yes,
  61.             no
  62.         }
  63.  
  64.         static bool CheckFirstRule(OutlookOptions outlook, HumidityOptions humidity, PlayOptions play)
  65.         {
  66.             if (outlook == OutlookOptions.sunny && humidity == HumidityOptions.high && play == PlayOptions.no)
  67.             {
  68.                 Program.firstRuleFounds++;
  69.                 return true;
  70.             }
  71.  
  72.             return false;
  73.         }
  74.  
  75.         static bool CheckSecondRule(OutlookOptions outlook, WindyOptions windy, PlayOptions play)
  76.         {
  77.             if (outlook == OutlookOptions.rainy && windy == WindyOptions.TRUE && play == PlayOptions.no)
  78.             {
  79.                 Program.secondRuleFounds++;
  80.                 return true;
  81.             }
  82.  
  83.             return false;
  84.         }
  85.  
  86.         static bool CheckThirdRule(OutlookOptions outlook, PlayOptions play)
  87.         {
  88.             if (outlook == OutlookOptions.overcast && play == PlayOptions.yes)
  89.             {
  90.                 Program.thirdRuleFounds++;
  91.                 return true;
  92.             }
  93.  
  94.             return false;
  95.         }
  96.  
  97.         static bool CheckFourthRule(HumidityOptions humidity, PlayOptions play)
  98.         {
  99.             if (humidity == HumidityOptions.normal && play == PlayOptions.yes)
  100.             {
  101.                 Program.fourthRuleFounds++;
  102.                 return true;
  103.             }
  104.  
  105.             return false;
  106.         }
  107.  
  108.         static void AddToFifthFiRule()
  109.         {
  110.             Program.fifthRuleFounds++;
  111.         }
  112.  
  113.         public static void Main(string[] args)
  114.         {
  115.             foreach(OutlookOptions outlook in Enum.GetValues(typeof(OutlookOptions)))
  116.             {
  117.                 foreach (TemperatureOptions temperature in Enum.GetValues(typeof(TemperatureOptions)))
  118.                 {
  119.                     foreach (HumidityOptions humidity in Enum.GetValues(typeof(HumidityOptions)))
  120.                     {
  121.                         foreach (WindyOptions windy in Enum.GetValues(typeof(WindyOptions)))
  122.                         {
  123.                             foreach (PlayOptions play in Enum.GetValues(typeof(PlayOptions)))
  124.                             {
  125.                                 allIterationsCount++;
  126.                                 if (
  127.                                     !CheckFirstRule(outlook, humidity, play)
  128.                                     && !CheckSecondRule(outlook, windy, play)
  129.                                     && !CheckThirdRule(outlook, play)
  130.                                     && !CheckFourthRule(humidity, play)
  131.                                 )
  132.                                 {
  133.                                     AddToFifthFiRule();
  134.                                 }
  135.                             }
  136.                         }
  137.                     }
  138.                 }
  139.             }
  140.  
  141.             Console.WriteLine(allIterationsCount);
  142.             Console.WriteLine(firstRuleFounds);
  143.             Console.WriteLine(secondRuleFounds);
  144.             Console.WriteLine(thirdRuleFounds);
  145.             Console.WriteLine(fourthRuleFounds);
  146.             Console.WriteLine(fifthRuleFounds);
  147.             Console.ReadKey();
  148.         }
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement