name = $inArr[0]; $this->street = ""; $this->city = $inArr[1]; $this->state = $inArr[2]; $this->zip = ""; break; case 5: $this->name = $inArr[0]; $this->street = $inArr[1]; $this->city = $inArr[2]; $this->state = $inArr[3]; $this->zip = $inArr[4]; break; default: throw new Exception("$arrLength parameters not supported"); } } public function display(){ echo "
\n";
echo "Name: " . $this->name . "
\n";
echo "Street: " . $this->street . "
\n";
echo "City: " . $this->city . "
\n";
echo "State: " . $this->state . "
\n";
echo "Zip: " . $this->zip . "
\n";
echo "
Create an object and display it.
display(); ?>Change the object contents and display them.
setName("Jane Doe"); echo "New name is: " . $anAddress->getName() . "
\n"; $anAddress->setCity("Los Angeles"); echo "New city is: " . $anAddress->getCity() . "
\n"; $anAddress->setState("CA"); echo "New state is: " . $anAddress->getState() . "
\n"; $anAddress->display(); ?> display(); // This throws exception $anAddress2 = new Address(array("John Doe", "New York")); $anAddress2->display(); ?>