Created
August 31, 2009 04:23
-
-
Save ccarpenterg/178276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Gestor { | |
Private $arr; | |
Private $largo; | |
function __construct($arreglo) { | |
$this->arr = $arreglo; | |
$this->_largo(); | |
} | |
Private function _largo() { | |
$this->largo = count($this->arr); | |
} | |
Public function elementos() { | |
echo $this->largo; | |
} | |
Public function promedio() { | |
$sum = 0; | |
$this->_largo(); | |
foreach($this->arr as $valor) { | |
$sum += $valor; | |
} | |
$prom = $sum / $this->largo; | |
echo $prom; | |
} | |
} | |
$arreglo = array(3, 12, 34); | |
$obj = new Gestor($arreglo); | |
$obj->largo = 5; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment