name, $this->gender, $this->age, $this->type, $this->os,
$min, $max) = explode(",", $serial);
$this->range = new Range($min, $max);
}
// Return whether the current Nerd matches with another given Nerd
public function checkMatch($other) {
return $this->os == $other->os
&& $this->range->inRange($other->age)
&& $other->range->inRange($this->age)
&& similar_text($this->type, $other->type) >= 1
&& $this->gender != $other->gender;
}
// Outputs an HTML representation of the current Nerd
public function outputHTML() {
?>
= $this->name ?>
- gender: = $this->gender ?>
- age: = $this->age ?>
- type: = $this->type ?>
- OS: = $this->os ?>
name;
}
}
// A class representing a number range. Very simple example class.
class Range {
public $min;
public $max;
// Constructs a new range with the given minimum and maximum
public function __construct($min, $max) {
$this->min = $min;
$this->max = $max;
}
// Returns whether the given number lies within the current Range
public function inRange($num) {
return ($num >= $this->min && $num <= $this->max);
}
// Returns a string representation of the range
public function __toString() {
return "[{$this->min}, {$this->max}]";
}
}
?>