owner = $owner;
}
// Set the owner of the account.
function set_owner($o)
{
$this->owner = $o;
}
// Print the name, too.
function pr($targs = "",
$karg = 'style="text-align: right; padding-left: 10pt;"',
$darg = 'style="text-align: left;"')
{
echo "Account for ", $this->owner, ":
";
parent::pr($targs, $karg, $darg);
}
}
// Not too different.
$aca = new NamedAccount('John Smith',
array('Jellybeans' => 200, 'Dustbunnies' => 250));
$acb = new NamedAccount
('Alice Jones', array('Snakes' => 500,
'Iguanas' => 220, 'Lizards' => 110));
$aca->pr();
$acb->pr();
echo "
"; $aca->xfer('Dustbunnies', 'Jellybeans', 55); $acb->xfer('Iguanas', 'Lizards', 50); $acb->xfer('Snakes', 'Lizards', 80); $aca->pr(); $acb->pr(); ?>