1 22 package org.objectweb.petals.demo.mortgage.profiler; 23 24 import javax.jws.WebMethod; 25 import javax.jws.WebParam; 26 import javax.jws.WebService; 27 28 34 @WebService(targetNamespace = "http://petals.objectweb.org/") 35 public class ProfilerImpl { 36 37 58 @WebMethod 59 public String evaluateDetailedProfile(@WebParam(name = "salary") 60 float salary, @WebParam(name = "propertyTaxes") 61 float propertyTaxes, @WebParam(name = "insurance") 62 float insurance, @WebParam(name = "autoPayment") 63 float autoPayment, @WebParam(name = "creditCards") 64 float creditCards, @WebParam(name = "otherPayments") 65 float otherPayments) { 66 System.out.println("ProfilerImpl : evaluateDetailedProfile - " + salary 67 + " " + propertyTaxes + " " + insurance + " " + autoPayment 68 + " " + creditCards + " " + otherPayments); 69 String result = "good"; 70 float debtRate = calculateDebtRate(salary, propertyTaxes, insurance, 71 autoPayment, creditCards, otherPayments); 72 77 if (debtRate > 50) { 78 result = "risky"; 79 } else if (debtRate > 33) { 80 result = "medium"; 81 } 82 System.out.println("ProfilerImpl : evaluateDetailedProfile - debRate " 83 + debtRate + " Evaluation " + result); 84 return result; 85 } 86 87 106 @WebMethod 107 public String evaluateSimpleProfile(@WebParam(name = "salary") 108 float salary, @WebParam(name = "propertyTaxes") 109 float propertyTaxes, @WebParam(name = "insurance") 110 float insurance, @WebParam(name = "autoPayment") 111 float autoPayment, @WebParam(name = "creditCards") 112 float creditCards, @WebParam(name = "otherPayments") 113 float otherPayments) { 114 System.out.println("ProfilerImpl : evaluateSimpleProfile - " + salary 115 + " " + propertyTaxes + " " + insurance + " " + autoPayment 116 + " " + creditCards + " " + otherPayments); 117 String result = "yes"; 118 119 float debtRate = calculateDebtRate(salary, propertyTaxes, insurance, 120 autoPayment, creditCards, otherPayments); 121 124 if (debtRate > 50) { 125 result = "no"; 126 } 127 System.out.println("ProfilerImpl : evaluateSimpleProfile - debRate " 128 + debtRate + " Mortgage possible " + result); 129 return result; 130 } 131 132 151 private float calculateDebtRate(float salary, float propertyTaxes, 152 float insurance, float autoPayment, float creditCards, 153 float otherPayments) { 154 157 float outgoings = propertyTaxes + insurance + autoPayment + creditCards 158 + otherPayments; 159 162 float debtRate = (100 * outgoings) / salary; 163 164 return debtRate; 165 } 166 } 167 | Popular Tags |