measure.cpp
/*
  TODO: Measure::getDifferenceAsPercentage()

  Calculate the difference between the first and last year imported as a 
  percentage. This function should be callable from a constant context and
  must promise to not change the state of the instance or throw an exception.

  @return
    The difference/change in value from the first to the last year as a decminal
    value, or 0 if it cannot be calculated

  @example
    Measure measure("pop", "Population");
    measure.setValue(1990, 12345678.9);
    measure.setValue(2010, 12345679.9);
    auto diff = measure.getDifferenceAsPercentage();
*/
:getDifferenceAsPercentage()
Calculate the difference between the first and last year imported as a
percentage. This function should be callable from a constant context and
must promise to not change the state of the instance or throw an exception.
: getDifferenceAsPercentage () Calculate the difference between the first and last year imported as a percentage . This function should be callable from a constant context and must promise to not change the state of the instance or throw an exception .
double Measure::getDifferenceAsPercentage(){
  double denominator = values.begin()->second;
  double difference = this->getDifference();
  if(denominator ==  0 || difference == 0){
    return 0;
  }
  return difference/denominator;
}
double Measure :: getDifferenceAsPercentage ( ) { double denominator = values . begin ( ) -> second ; double difference = this -> getDifference ( ) ; if ( denominator == 0 || difference == 0 ) { return 0 ; } return difference / denominator ; }
TODO: Measure::getDifferenceAsPercentage()
Calculate the difference between the first and last year imported as a
percentage.
TODO : Measure :: getDifferenceAsPercentage () Calculate the difference between the first and last year imported as a percentage .