#include<iostream>
using namespace std;


/* Each cow has a location in the field (which
  is just a single number), and a weight. */
class Cow
{
public:
 // Functions to directly access and set
 // variables
 void set(float inLocation, float inWeight);
 float getWeight();
 void getWeight(float& wt);
 float getLocation();

 // Cow actions that will change its member
 // variables
 void walk(float distance); // Move from current location
                            // as in Dog::Walk function,
                            // distance specified as float
 void graze(int hours);  // Increase weight by 1 for each
                         // hour grazing (hours entered)
                         // as integer

private:
 float location, weight;
 void Moo();
};


// ---------HERE IS THE MAIN FUNCTION----------
int main()
{
 // Declare and initialize Darren the Cow
 Cow darren;
 darren.set(10,150);


 // Output Darren's weight
 cout << "Darren\'s weight is " << darren.getWeight()
      << endl;

 // Time to eat!
 darren.graze(10);

 float newWeight;
 darren.getWeight(newWeight);  // use pass-by-reference!


 // Output Darren's new weight
 cout << "Darren\'s weight is now "
      << darren.getWeight() << endl;

 return 0;
}


// --HERE ARE THE ADDITIONAL FUNCTION DEFINITIONS--
// Set values of a cow object
void Cow::set(float inLocation, float inWeight)
{
 location=inLocation;
 weight=inWeight;
}


// Get weight of a cow object
float Cow::getWeight()
{
 return weight;
}


// Get weight of a cow object, using call-by-reference
void Cow::getWeight(float& wt)
{
 wt=weight;
}


// Get location of a cow object
float Cow::getLocation()
{
 return location;
}


// Move cow
void Cow::walk(float distance)
{
 location+=distance;
}


// Increase cow's weight based on grazing time
void Cow::graze(int hours)
{
 weight+=1*hours; // increase 1lb per hour

 if(hours>3)
   Moo();
}


// Print "Moooo" to screen
void Cow::Moo()
{
 cout << "Moooo\n";
}