Well, there's a few things to thing about here, but you know that you need $age and $color properties, and ways to read those properties. Chances are, you don't want to be able to write them though.
So, I would probably have:
getAge(){ return $this->age; }
getColor(){ return $this->color; }
Now, you want to assign the color and age randomly, which means you need the rand function (there are other options there, but rand will do you well). Now, if I were to do this, I would put something like this in the constructor:
// assuming we're testing for male or female
// you really should look into why this works.
$this->gender = ( rand( 0, 1 ) )? self::MALE: self::FEMALE;
// notice the self::MALE and self::FEMALE? Those are class constants.
// http://php.net/manual/en/language.oop5.constants.php
// if you want to get this question *right* you'll need to look at those
Your machines are actually pretty simple. They only test whether each sheep is old enough to be shorn and then they increment a counter based on that.
// assuming they are looking for a count of female sheep
// and state variables 'male' and 'female' which are initialized at 0
function processSheep( $sheep )
{
foreach( $sheep as $test )// stupid self-pluralizing nouns.
{
if( $sheep->getGender() == Sheep::MALE ) $this->males++;
else $this->females++; // obviously, you're going to need to swap
// out one of these increments for an echo.
}
}
function getNumberOfMales(){ return $this->males; }
With two machines, to calculate the number of males:
$mach1->getNumberOfMales() + $mach2->getNumberOfMales();
With an array of n machines, the number of males:
$males = 0;
foreach( $machs as $mach ){ $males += $mach->getNumberOfMales(); }