I have a general interface named Person and a class named Validator for the start. But I need help, see the question below the code, please !....
Then, I create the classes:
Code: Select all
<?php
require ('interface.Person.php');
require ('class.Validator.php');
class Employee implements Person {
private $_name;
//constructor for the Employee class
public function Employee ($name) {
$validator = new Validator();
//the isChar($param) function is already hard-coded in the Validator class
if ($validator->isChar($name)) {
$this->_name = $name;
} else {
throw new Exception ('ERROR: Employee name must be characters, not numbers.');
}
} //end constructor
//method to set and get the name
public function _setName ($name) {
if ($validator->isChar($name) {
$this->_name = $name;
} else {
throw new Exception ('ERROR: Employee name must be characters, not numbers.');
}
}
public function _getName() {
if (isset($this->_name)) {
return $this->_name;
} else {
throw new Exception ('ERROR: This employee name has not yet set, please set one.');
}
}
}
?>Thanks,
Chris