Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSeth Warner
5,348 PointsIm suppose to assign each property on the fish class with its corrosponding parameter variable, have I not done that?
<?php
class Fish {
public $common_name = 'default_name';
public $flavor = 'default_flavor';
public $record_weight = 0;
function __construct($name, $flavor, $record){
$this->name = $name;
$this->flavor = $flavor;
$this->record = $record;
}
}
?>
<?php
class Fish {
public $common_name = 'default_name';
public $flavor = 'default_flavor';
public $record_weight = 0;
function __construct($name, $flavor, $record){
$this->name = $name;
$this->flavor = $flavor;
$this->record = $record;
}
}
?>
1 Answer
thomascawthorn
22,986 PointsHere you've assigned properties 'name', 'flavor' and 'record'
<?php
$this->name = $name;
$this->flavor = $flavor;
$this->record = $record;
but you've set your properties as 'common_name', 'flavor' and 'record_weight'.
<?php
public $common_name = 'default_name';
public $flavor = 'default_flavor';
public $record_weight = 0;
You're probably looking to match the two up, you could do this:
<?php
$this->common_name = $name;
$this->flavor = $flavor;
$this->record_weight = $record;