Android Open Source - android-nfl-passer-rating Ncaa Passer Rating






From Project

Back to project page android-nfl-passer-rating.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project android-nfl-passer-rating listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * This is free and unencumbered software released into the public domain.
 * /*  w w w .j  av  a 2  s  . c  om*/
 * Anyone is free to copy, modify, publish, use, compile, sell, or
 * distribute this software, either in source code form or as a compiled
 * binary, for any purpose, commercial or non-commercial, and by any
 * means.
 * 
 * In jurisdictions that recognize copyright laws, the author or authors
 * of this software dedicate any and all copyright interest in the
 * software to the public domain. We make this dedication for the benefit
 * of the public at large and to the detriment of our heirs and
 * successors. We intend this dedication to be an overt act of
 * relinquishment in perpetuity of all present and future rights to this
 * software under copyright law.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * 
 * For more information, please refer to <http://unlicense.org/>
 */


package com.github.pffy.sports;

/**
 * This object calculates the NCAA College Football League passer rating.
 * @author The Pffy Authors
 * 
 */
public class NcaaPasserRating extends AbstractPasserRating {

  /**
   * Builds this object.
   */
  public NcaaPasserRating() { }
  

  /**
   * Builds this object with all parameters.
   * 
   * @param completedPasses
   * @param attemptedPasses
   * @param yardsPassing
   * @param touchdownPasses
   * @param interceptedPasses
   */
  public NcaaPasserRating(double completedPasses, double attemptedPasses, double yardsPassing,
      double touchdownPasses, double interceptedPasses) {
   
    super();
    this.completedPasses = completedPasses;
    this.attemptedPasses = attemptedPasses;
    this.yardsPassing = yardsPassing;
    this.touchdownPasses = touchdownPasses;
    this.interceptedPasses = interceptedPasses;
  }

  /**
   * Returns the NCAA passer rating.
   * 
   * @return rating NCAA passer rating.
   * 
   */
  public double getRating()
  {
    double m = 0.0;
    
    try {      
      m = ( 8.4 * this.yardsPassing + 330 * this.touchdownPasses + 
          100 * this.completedPasses  - 200 * this.interceptedPasses ) / this.attemptedPasses;
      
      m = Math.max(-200, Math.min(m, 1261.6));
      
      return Math.round(m * 10.0) / 10.0;
    } catch (Exception e) {
      e.printStackTrace();
      return 0.0;
    }
  }
}




Java Source Code List

com.github.pffy.qbrating.PasserRatingActivity.java
com.github.pffy.sports.AbstractPasserRating.java
com.github.pffy.sports.AflPasserRating.java
com.github.pffy.sports.NcaaPasserRating.java
com.github.pffy.sports.NflPasserRating.java