<?php
class box
{
var $height;
var $width;
var $depth;
var $front_area;
var $side_area;
var $top_area;
var $volume;
function areas()
{
$this->front_area = $this->height * $this->width;
$this->side_area = $this->height * $this->depth;
$this->top_area = $this->width * $this->depth;
}
function volume()
{
$this->volume = $this->height * $this->width * $this->depth;
}
}
$big_box = new box;
$big_box->height = 20;
$big_box->width = 30;
$big_box->depth = 50;
$big_box->areas();
$big_box->volume();
$small_box = new box;
$small_box->height = 5;
$small_box->width = 3;
$small_box->depth = 4;
$small_box->areas();
$small_box->volume();
echo "The small box front area is: ".$small_box->front_area." square units and the big box front area is: ".$big_box->front_area." square units.<br>";
?>
This post has been edited by CTphpnwb: 16 December 2008 - 09:00 PM

New Topic/Question
Reply





MultiQuote





|