/* 
 *      //\\
 *    ////\\\\	  Project Bayanihan
 *   o |.[].|o 
 *  -->|....|->-  Worldwide Volunteer Computing Using Java
 *  o o.o.o.o\<\  
 * -->->->->->-   Copyright 1999, Luis F. G. Sarmenta.
 *   <\<\<\<\<\   All rights reserved.
 * 
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * and disclaimer appear in all copies.
 *
 * LUIS F. G. SARMENTA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
 * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
 * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. LUIS F. G. SARMENTA
 * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT
 * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 * ----------------------------------------------------------------------------|
 */
package bayanihan.apps.ftsim;

import java.util.*;
import bayanihan.util.*;

/**
 */
public class VotingCredWorkEntry2 extends VotingCredWorkEntry 
{
   //////////////////
   // Constructors //
   //////////////////

   /**
    * This no-arg constructor does not create any data.  You must
    * set the data yourself by calling setData().
    */
   public VotingCredWorkEntry2()
   {
      // super;
   }
   
   public VotingCredWorkEntry2( double f, double h, double cThresh )
   {
      super( f, h, cThresh );
   }
   
   ////////////////////
   // Initialization //
   ////////////////////
   
   //////////////////////
   // Accessor methods //
   //////////////////////
   
   /**
    * Sets the WorkEntry's done flag and sets its associated single
    * (usually final) result at the same time.
    */
   public void setDone( ResultEntry resultEntry )
   {
      if ( !this.isDone() )
      {
         // note: we MAY want to collect results even if 
         // this is done, just in case some of them get backtracked.
         
         // but anyway, don't for now, to make credibilities
         // a bit more controllable.
      
         CredResultEntry credResEntry = (CredResultEntry)resultEntry;
      
         boolean foundMatch = false;
      
         for ( int i = 0; !foundMatch && ( i < groups.size() ); i++ )
         {
            if ( ((ResultGroup)groups.elementAt( i )).checkAndAddResultEntry( 
                                                         credResEntry ) )
            {
               foundMatch = true;
            }
         }
      
         if ( !foundMatch )
         {
            groups.addElement( new ResultGroup2( credResEntry ) );  // <--------
         }
      
         this.checkDone( this.getCred() );
      }
   }
}


