The way the assignment is written, we have to test inside the constructor for errors as the new item is made. I think this is supposed to be bad practice, but it is the way the instructor wants it.
I tired setting up a variable outside the constructor that the setter methods could test against, but it seems that PHP method do not allow for use of variables out side of the the class scope. Is that right?
had to set up a setter method inside the class to set my variables, but it won't recognize my variables inside the class either.
I have a method that creates and then another method that tests. Is that wrong?
public function setVariety($variety)
{
$this->variety=array("road","mountain","hybrid","motorcross");
}
//set the kind of bike (Mountain, road, hybrid,motocross)
public function setType($type)
{
$type=strtolower($type);
if (in_array($type,$variety))
$this->type=$type;
else echo "The bike $type was not of the correct variety\n";
The way I see the set up for the problem, we are supposed to set up testers that are variable based.
It looks like this is not possible.