Advertisement
AyaAbouzeid

Untitled

May 3rd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. String[] implicants = new String [30];
  2.     int implicantscounter =0 ;
  3. public void findimplicants(){
  4.  
  5. for (int i=0 ; i< binary.length ; i++) {
  6.    
  7.     String  temp = binary[i];
  8.     Boolean found = false ;
  9.     int maximum = -1;
  10.     for(int j=0 ; j <evaluated.length ; j++) {
  11.        
  12.         if(match(evaluated[j],temp)){
  13.            
  14.             if(found== false){
  15.                
  16.                 found = true ;
  17.            
  18.                 maximum = dashes(evaluated[j]);
  19.                
  20.                 addimplicants(evaluated[j]);
  21.             }
  22.             if(found== true && maximum == dashes(evaluated[j]) ){
  23.                 addimplicants(evaluated[j]);
  24.                
  25.            
  26.         }
  27.        
  28.     }
  29.    
  30. }
  31.  
  32. }
  33. }
  34.  
  35. public void addimplicants(String s1){
  36.    
  37.    
  38.     Boolean found = false ;
  39.     for(int i=0 ; i < implicantscounter ; i++){
  40.         if(s1.equals(implicants[i])){
  41.            
  42.             found = true ;
  43.         }
  44.        
  45.     }
  46.     if(found==false){
  47.        
  48.         implicants[implicantscounter]= s1;
  49.         implicantscounter ++;
  50.     }
  51.    
  52. }
  53.  
  54. public int dashes(String s1 ){
  55.    
  56.     int counter=0 ;
  57.     int length = s1.length();
  58.     for(int i=0 ; i<length ; i++){
  59.        
  60.         if(s1.charAt(i) == '_'){
  61.            
  62.             counter++;
  63.         }
  64.        
  65.     }
  66.    
  67.     return counter ;
  68. }
  69.  
  70. int[] value = new int[binary.length];
  71. public void recursion(int index){
  72.    
  73.     if(index>= implicantscounter)
  74.    
  75.     {
  76.         return;
  77.        
  78.     }
  79.    
  80. ayesm(implicants[index],1);
  81. ayesm(implicants[index],-1);
  82.    
  83. }
  84.  
  85. public void checkdone(){
  86.    
  87.     for(int i=0 ; i <value.length ; i++){
  88.        
  89.         if(value[i]==0){
  90.             return;
  91.         }
  92.        
  93.     }
  94.    
  95.    
  96.    
  97. }
  98.  
  99.  
  100. public void ayesm (String s1 , int val){
  101.    
  102.     for(int i =0 ; i <binary.length ; i++){
  103.        
  104.        
  105.         if ( match(s1,binary[i])){
  106.            
  107.             value[i]+= val;
  108.         }
  109.        
  110.        
  111.     }
  112.    
  113. }
  114.  
  115.  
  116.  
  117. public boolean match(String s1 , String s2){
  118.    
  119.    
  120.     int length = s1.length();
  121.     for(int i=0 ; i<length ; i++){
  122.        
  123.         if(s1.charAt(i) == '_'){
  124.            
  125.             continue;
  126.         }
  127.         if(s1.charAt(i) != s2.charAt(i))
  128.         {
  129.             return false ;
  130.         }
  131.     }
  132.    
  133.     return true ;
  134. }
  135. public void printevaluated(){
  136.    
  137.     for(int i =0 ; i < size ; i++ ){
  138.        
  139.         System.out.println(evaluated[i]);
  140.     }
  141.    
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement