コード例 #1
0
  public void setChildSupportFemale() {

    float i = 0;
    int numFemales = lstDivFemalesWithChild.size();

    // While less than 75% of women receive child support
    while (i < numFemales * .75) {

      randomFemale = randomGenerator.nextInt(lstDivFemalesWithChild.size());
      // Get a random female with children
      Survey survey = lstDivFemalesWithChild.get(randomFemale);

      // Get job information from survey
      Job jobInfo = Controller.getInstance().getJob("id", Integer.toString(survey.getJob()));
      // TODO: do we need to take tax out of this equation?
      double salary = jobInfo.getAnnGrossSal();
      // Assign child support based on income and number of children
      if (survey.getChildren() == 1) {
        survey.setChildSupport(.0116 * salary);
        lstDivFemalesWithChild.remove(survey);
      }
      if (survey.getChildren() == 2) {
        survey.setChildSupport(.0174 * salary);
        lstDivFemalesWithChild.remove(survey);
      }
      i++;

      System.out.println("i = : " + i);
      System.out.println("child support/Female: " + survey.getChildSupport());
    }

    // For remaining women, assign child support payment based on income
    for (Survey survey2 : lstDivFemalesWithChild) {

      Job jobInfo = Controller.getInstance().getJob("id", Integer.toString(survey2.getJob()));
      // TODO: do we need to take tax out of this equation?
      double salary = jobInfo.getAnnGrossSal();

      if (survey2.getChildSupport() == 0) {
        if (survey2.getChildren() == 1) {
          survey2.setChildSupport(-(.0116 * salary));
          System.out.println("Came from neg.: " + survey2.getChildSupport());
        }
        if (survey2.getChildren() == 2) {
          survey2.setChildSupport(-(.0174 * salary));
          System.out.println("Came from neg.: " + survey2.getChildSupport());
        }
      }
    }
  } // end setChildSupportFemale()
コード例 #2
0
  public void setChildSupportMale() {

    // set 'i' to '1' for groups of 10 or more. If 'i' is not '0'no male in a group under 10 will
    // receive child support
    int i = 0;

    // While less than 10% of men receive child support
    while (i <= lstDivMalesWithChild.size() * .1) {

      randomMale = randomGenerator.nextInt(lstDivMalesWithChild.size());
      // Get a random male with children
      Survey survey = lstDivMalesWithChild.get(randomMale);
      // Get job info for survey
      Job jobInfo = Controller.getInstance().getJob("id", Integer.toString(survey.getJob()));
      // TODO: do we need to take tax out of this equation?
      double salary = jobInfo.getAnnGrossSal();
      // Assign child support based on income and number of children
      if (survey.getChildren() == 1) {
        survey.setChildSupport(.0116 * salary);
        lstDivMalesWithChild.remove(survey);
      }
      if (survey.getChildren() == 2) {
        survey.setChildSupport(.0174 * salary);
        lstDivMalesWithChild.remove(survey);
      }

      i++;
      System.out.println("child support: " + survey.getChildSupport());
    } // emd while

    // Set all other males to pay child support based on their income
    for (Survey survey2 : lstDivMalesWithChild) {

      Job jobInfo = Controller.getInstance().getJob("id", Integer.toString(survey2.getJob()));
      // TODO: do we need to take tax out of this equation?
      double salary = jobInfo.getAnnGrossSal();

      if (survey2.getChildSupport() == 0) {
        if (survey2.getChildren() == 1) {
          survey2.setChildSupport(-(.0116 * salary));
        }
        if (survey2.getChildren() == 2) {
          survey2.setChildSupport(-(.0174 * salary));
        }
      }
    }
  } // end setChildSupportMale()