#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:
float location, weight;
// Functions to directly access and set
// variables
void set(float inLocation, float inWeight);
float getWeight();
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
};
// ---------HERE IS THE MAIN FUNCTION----------
int main()
{
// You may delete this cout statement:
cout << "Add cows to this progam!\n";
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 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
}