Help with PHP class to find area of a shape?

  • Thread starter Thread starter Chris G
  • Start date Start date
C

Chris G

Guest
What I'd like to do is create a class which allows you to create a shape... something like:

$square = $create->shape(4, 5, 5, 5, 5);
* This example would create a square (4 sides) with all sides equal to a length of 5 and stores it in a variable with the name of 'square' for later use.

Then another class to solve various mathematical equations for the shape...like finding the area...

echo $solve->area($square);
* This finds the area of the square created.

Can someone PLEASE help me get started in the right direction on this?
FYI - I know how to construct and instantiate a class...so a tutorial of this isn't what I'm looking for.

I'm looking for some guidance on creating a class which creates a shape and finds its area...

Thank you, though. =)
 
Class Joe {

var $Title,
$KeyWords,
$Content;

function Display() {
echo "<html>\n<head>";
$this->DisplayTitle();
$this->DisplayKeyWords();
echo "</head>\n<body>\n";
echo $this->$Content;
echo "</body>\n</html>\n";
}

function DisplayTitle() {
echo "<TITLE>" . $this->Title . "</TITLE>";
}

function DisplayKeyWords() {
echo '<META NAME="Keywords" CONTENT="' . $this->KeyWords . '">';
}

function SetContent ( $Data ){
$this->Content = $Data;
}
}


$Sample = new Joe;

$Content = "<p>This is the content of the class.</p>";

$Sample->Title = "MY 1st PHP Class";
$Sample->KeyWords = "PHP, Classes";
$Sample->SetContent($Content);

$Sample->Display();
 
Back
Top