Advertisement
stevekamau

Untitled

Nov 19th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package utility;
  2.  
  3. import android.app.Activity;
  4.  
  5. /**
  6.  * Created by steve on 11/17/16.
  7.  */
  8.  
  9. public class CompletenessScore {
  10.     AccountSharedPreferences ap;
  11.     private int address = 0;
  12.     private int businessUsername = 0;
  13.     private int city = 0;
  14.     private int country = 0;
  15.     private int currency = 0;
  16.     private int phone = 0;
  17.     private int desciption = 0;
  18.     private int website = 0;
  19.     private int logo = 0;
  20.  
  21.     public CompletenessScore(Activity activity) {
  22.         ap = new AccountSharedPreferences(activity);
  23.     }
  24.  
  25.     public int CalculateCompletenessScore() {
  26.         if (ap.getAddress().length() > 0) {
  27.             address = 1;
  28.         }
  29.         if (ap.getBusinessUserName().length() > 0) {
  30.             businessUsername = 1;
  31.         }
  32.         if (ap.getCity().length() > 0) {
  33.             city = 1;
  34.         }
  35.         if (ap.getCountry().length() > 0) {
  36.             country = 1;
  37.         }
  38.         if (ap.getCurrency().length() > 0) {
  39.             currency = 1;
  40.         }
  41.         if (ap.getPhone().length() > 0) {
  42.             phone = 1;
  43.         }
  44.         if (ap.getDescription().length() > 0) {
  45.             desciption = 1;
  46.         }
  47.         if (ap.getWebsite().length() > 0) {
  48.             website = 1;
  49.         }
  50.         if (ap.getLogo().length() > 0) {
  51.             logo = 1;
  52.         }
  53.         int sum = address + businessUsername + city + country + currency + phone + desciption + website + logo;
  54.         double finalScore = (sum / (double) 9) * 100;
  55. //        double finalScore = (4/ (double) 8) * 100;
  56.         return (int) finalScore;
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement