Coverage report

  %line %branch
ca.spaz.cron.database.Measure
27% 
93% 

 1  
 /*
 2  
  * Created on 19-Mar-2005
 3  
  */
 4  
 package ca.spaz.cron.database;
 5  
 
 6  
 
 7  
 /**
 8  
  * A measure maps a common measure for a food item (ie: a Cup, Teaspoon,
 9  
  * Serving, etc...) The Measure contains the description of the measure and the
 10  
  * number of grams of the food there are in the given measure.
 11  
  * 
 12  
  * @author davidson
 13  
  */
 14  7
 public class Measure {
 15  
     // The default, standard measure, a Gram (g)
 16  10
     public final static Measure GRAM = new Measure(1.0, "g", 1.0);
 17  
 
 18  
     private double grams; // number of grams in the food
 19  
 
 20  
     private double amount; // multiplier for the measure
 21  
 
 22  
     private String description; // description of the measure
 23  
 
 24  10
     private int ID = -1;
 25  10
     private int FID = -1;
 26  
     
 27  0
     public Measure() {
 28  0
     }
 29  
 
 30  
     /**
 31  
      * Contruct a measure manually
 32  
      * 
 33  
      * @param amount
 34  
      *            the multiplier of the measure (ex: 0.5)
 35  
      * @param description
 36  
      *            the measure name (ex: Cups)
 37  
      * @param grams
 38  
      *            the number of grams in the multiple of this type (ex: grams in
 39  
      *            1/2 a Cup)
 40  
      */
 41  10
     public Measure(double amount, String description, class="keyword">double grams) {
 42  10
         this.amount = amount;
 43  10
         this.description = description;
 44  10
         this.grams = grams;
 45  10
     }
 46  
 
 47  
     /**
 48  
      * Get the standard amount of this measure. Example: 1.0 Servings, 0.5 Cups,
 49  
      * 2.0 Tablespoons
 50  
      * 
 51  
      * @return the multiplier for this measure
 52  
      */
 53  
     public double getAmount() {
 54  0
         return amount;
 55  
     }
 56  
 
 57  
     /**
 58  
      * Set the standard amount of this measure
 59  
      * 
 60  
      * @param amount
 61  
      *            a multiplier
 62  
      */
 63  
     public void setAmount(double amount) {
 64  0
         this.amount = amount;
 65  0
     }
 66  
 
 67  
     /**
 68  
      * Get the english name of the measure type
 69  
      * 
 70  
      * @return the english name of the measure type
 71  
      */
 72  
     public String getDescription() {
 73  0
         return description;
 74  
     }
 75  
 
 76  
     /**
 77  
      * Set the english name of this measure type
 78  
      */
 79  
     public void setDescription(String description) {
 80  0
         this.description = description;
 81  0
     }
 82  
 
 83  
     /**
 84  
      * Get the number of grams in this measure
 85  
      * 
 86  
      * @return the number of grams in the measure
 87  
      */
 88  
     public double getGrams() {
 89  0
         return grams;
 90  
     }
 91  
 
 92  
     /**
 93  
      * Set the number of grams in this measure
 94  
      */
 95  
     public void setGrams(double grams) {
 96  0
         this.grams = grams;
 97  0
     }
 98  
 
 99  
     public String toString() {
 100  0
        if (amount != 1.0) {
 101  0
           if (amount == 0.5) {
 102  0
              return "1/2 " + description;
 103  
           }
 104  0
           if (amount == (int)amount) {
 105  0
              return (int)amount + " " + description;
 106  
           }          
 107  0
           return amount + " " + description;
 108  
        }
 109  0
        return description;
 110  
     }
 111  
 
 112  
    public int getID() {
 113  0
       return ID;
 114  
    }
 115  
 
 116  
    public void setID(int id) {
 117  0
       ID = id;
 118  0
    }
 119  
    
 120  
    public int getFoodID() {
 121  0
       return FID;
 122  
    }
 123  
 
 124  
    public void setFoodID(int fid) {
 125  0
       FID = fid;
 126  0
    }
 127  
 
 128  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.