Pounds2KilosExercise.cpp

Go to the documentation of this file.
00001 #include "macros.h" // needs to be declared as first entry in .cpp or .h file!
00002 #include <string>
00003 #include <iostream>
00004 using namespace std;
00005 #include "AbstractExercise.h"
00006 
00012 class Pounds2KilosExercise : public AbstractExercise {
00013 public:
00014 
00020     Pounds2KilosExercise(string name) : AbstractExercise(name){};
00021 
00022 protected:
00023 
00028     void execute();
00029 
00034     void getInput();
00035 
00036 private:
00037 
00044     static double p2k(double pounds);
00045     
00052     static double k2p(double kilos);
00053 
00054     double fPounds;
00055     double fKilos;
00056 
00057 };
00058     
00064 namespace {
00065     Pounds2KilosExercise proto("Pounds2KilosExercise");
00066 }
00067 
00068 
00069 void Pounds2KilosExercise::getInput(){
00070     cout << "Enter pounds :";
00071     cin >>  fPounds;
00072     cout << "Enter kilos :";
00073     cin >>  fKilos;
00074 }
00075 
00076 void Pounds2KilosExercise::execute(){
00077     cout << fPounds <<"  p = "<< p2k(fPounds) << " kg" << endl;
00078     cout << fKilos  <<" kg = "<< k2p(fKilos)  << " p"  << endl;
00079 }
00080 
00081 const double POUND_IN_KILOS = 0.45;
00082 
00083 double Pounds2KilosExercise::p2k(double pounds){
00084     return pounds * POUND_IN_KILOS;
00085 }
00086 
00087 double Pounds2KilosExercise::k2p(double kilos){
00088     return kilos / POUND_IN_KILOS;
00089 }

Generated on Thu Jul 3 19:12:45 2008 for Exercise Framework by  doxygen 1.5.1