commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/distribution HypergeometricDistributionImpl.java
Date Tue, 11 May 2004 02:07:58 GMT
psteitz     2004/05/10 19:07:58

  Modified:    math/src/java/org/apache/commons/math/distribution
                        HypergeometricDistributionImpl.java
  Log:
  Added consistency checks for constructor parameters.
  
  Revision  Changes    Path
  1.12      +12 -5     jakarta-commons/math/src/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
  
  Index: HypergeometricDistributionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HypergeometricDistributionImpl.java	8 Apr 2004 20:45:59 -0000	1.11
  +++ HypergeometricDistributionImpl.java	11 May 2004 02:07:58 -0000	1.12
  @@ -47,9 +47,16 @@
        * @param sampleSize the sample size.
        */
       public HypergeometricDistributionImpl(int populationSize,
  -        int numberOfSuccesses, int sampleSize)
  -    {
  +        int numberOfSuccesses, int sampleSize) {
           super();
  +        if (numberOfSuccesses > populationSize) {
  +            throw new IllegalArgumentException(
  +            "number of successes must be less than or equal to population size");
  +        }
  +        if (sampleSize > populationSize) {
  +            throw new IllegalArgumentException(
  +            "sample size must be less than or equal to population size");
  +        }
           setPopulationSize(populationSize);
           setSampleSize(sampleSize);
           setNumberOfSuccesses(numberOfSuccesses);
  @@ -237,10 +244,10 @@
        * @param size the new sample size.
        */
       public void setSampleSize(int size) {
  -        if(size < 0){
  +        if (size < 0) {
               throw new IllegalArgumentException(
                   "sample size must be non-negative.");
  -        }
  +        }    
           sampleSize = size;
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message