Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MAD___CV1
- {
- class Program
- {
- private static int allIterationsCount = 0;
- //outlook == sunny && humidity == high && play == no
- private static int firstRuleFounds = 0;
- //outlook == rainy && windy == true && play == no
- private static int secondRuleFounds = 0;
- //outlook == overcast && play == yes
- private static int thirdRuleFounds = 0;
- //humidity == normal && play == yes
- private static int fourthRuleFounds = 0;
- //none of above play == yes
- private static int fifthRuleFounds = 0;
- enum OutlookOptions
- {
- sunny,
- overcast,
- rainy,
- none
- }
- enum TemperatureOptions
- {
- hot,
- mild,
- cool,
- none
- }
- enum HumidityOptions
- {
- high,
- normal,
- none
- }
- enum WindyOptions
- {
- TRUE,
- FALSE,
- none
- }
- enum PlayOptions
- {
- yes,
- no
- }
- static bool CheckFirstRule(OutlookOptions outlook, HumidityOptions humidity, PlayOptions play)
- {
- if (outlook == OutlookOptions.sunny && humidity == HumidityOptions.high && play == PlayOptions.no)
- {
- Program.firstRuleFounds++;
- return true;
- }
- return false;
- }
- static bool CheckSecondRule(OutlookOptions outlook, WindyOptions windy, PlayOptions play)
- {
- if (outlook == OutlookOptions.rainy && windy == WindyOptions.TRUE && play == PlayOptions.no)
- {
- Program.secondRuleFounds++;
- return true;
- }
- return false;
- }
- static bool CheckThirdRule(OutlookOptions outlook, PlayOptions play)
- {
- if (outlook == OutlookOptions.overcast && play == PlayOptions.yes)
- {
- Program.thirdRuleFounds++;
- return true;
- }
- return false;
- }
- static bool CheckFourthRule(HumidityOptions humidity, PlayOptions play)
- {
- if (humidity == HumidityOptions.normal && play == PlayOptions.yes)
- {
- Program.fourthRuleFounds++;
- return true;
- }
- return false;
- }
- static void AddToFifthFiRule()
- {
- Program.fifthRuleFounds++;
- }
- public static void Main(string[] args)
- {
- foreach(OutlookOptions outlook in Enum.GetValues(typeof(OutlookOptions)))
- {
- foreach (TemperatureOptions temperature in Enum.GetValues(typeof(TemperatureOptions)))
- {
- foreach (HumidityOptions humidity in Enum.GetValues(typeof(HumidityOptions)))
- {
- foreach (WindyOptions windy in Enum.GetValues(typeof(WindyOptions)))
- {
- foreach (PlayOptions play in Enum.GetValues(typeof(PlayOptions)))
- {
- allIterationsCount++;
- if (
- !CheckFirstRule(outlook, humidity, play)
- && !CheckSecondRule(outlook, windy, play)
- && !CheckThirdRule(outlook, play)
- && !CheckFourthRule(humidity, play)
- )
- {
- AddToFifthFiRule();
- }
- }
- }
- }
- }
- }
- Console.WriteLine(allIterationsCount);
- Console.WriteLine(firstRuleFounds);
- Console.WriteLine(secondRuleFounds);
- Console.WriteLine(thirdRuleFounds);
- Console.WriteLine(fourthRuleFounds);
- Console.WriteLine(fifthRuleFounds);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement