i have this code. It works, but is it possible to do this better ? With less code ?
public function __construct($type ,$brand, $model, $year, $mileage, $height, $width, $depth, $ps, $color, $price, $value, $seats)
{
if (is_int($type)) {
$this->_type = $type;
} else {
throw new Exception('Wrong Value in Type. Expected integer');
}
}
...
I create an object like this
try {
$firstCar = new Car(1, 'Audi', 'A3', 2011, 94512, 2, 2, 2, 105, 'Black', 1000, 1920, 5);
} catch ( Exception $error) {
die($error->getMessage());
}
I repeat the "IF-ELSE" Statement for every variable in 2 Classes. Its so much code.
Some suggestions out here?