Advertisement
hibbzboi

Regula.cs

May 16th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 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 Reguly
  8. {
  9.     public enum Zawieranie
  10.     {
  11.         Tak,
  12.         Nie,
  13.         Równe
  14.     }
  15.     public class Regula
  16.     {
  17.         public int decyzja;
  18.         public int support;
  19.         public List<Deskryptor> deskryptory = new List<Deskryptor>();
  20.  
  21.         public Regula(int[] kombinacja, int[] obiektSystemuDecyzyjnego)
  22.         {
  23.             this.decyzja = obiektSystemuDecyzyjnego.Last();
  24.  
  25.             foreach (var atrybucior in kombinacja)
  26.             {
  27.                 Deskryptor pojedyncznyDeskryptor = new Deskryptor(atrybucior, obiektSystemuDecyzyjnego[atrybucior]);
  28.  
  29.                 this.deskryptory.Add(pojedyncznyDeskryptor);
  30.             }
  31.         }
  32.  
  33.         public Zawieranie CzyZawiera (Regula regulaZListy)
  34.         {
  35.             Zawieranie decision = Zawieranie.Nie;
  36.  
  37.             foreach (var jedenDeskryptor in regulaZListy.deskryptory)
  38.             {
  39.                 if (this.deskryptory.Where(d => d.atrybut == jedenDeskryptor.atrybut && d.wartosc == jedenDeskryptor.wartosc).Count() < 1)
  40.                 {
  41.                     decision = Zawieranie.Tak;
  42.                 }
  43.             }
  44.  
  45.             if (regulaZListy.deskryptory.Count == this.deskryptory.Count)
  46.             {
  47.                 for (int i = 0; i < regulaZListy.deskryptory.Count; i++)
  48.                 {
  49.                     if (regulaZListy.deskryptory[i] == this.deskryptory[i])
  50.                     {
  51.                         return Zawieranie.Równe;
  52.                     }
  53.                 }
  54.                
  55.             }
  56.  
  57.             return decision;
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement