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 trialtonderayi masiyandima
5,673 PointsChallenge Task 2 of 3 Step 1: Add an additional array property
stuck on task 2 and 3 help please
<?php
//do not modify this file
class User {
protected $name;
protected $title;
public function __construct($name = null, $title = null) {
$this->name = $name;
$this->title = $title;
}
public function __toString() {
return $this->getSalutation();
}
public function getSalutation() {
return $this->title . " " . $this->name;
}
public function getName() {
return $this->name;
}
public function setName($name) {
$this->name = $name;
}
public function getTitle() {
return $this->title;
}
public function setTitle($title) {
$this->title = $title;
}
}
<?php
//add new child class here
Developer.php
<?php
//add new child class here
class Developer extends User
{
protected $skills = array();
public function setSkills($array)
{
$this->skills = $array;
}
public function getSkills()
{
return $this->skills;
}
public function displayUserSkills()
{
return $this->getName() . " has the following skills: " . implode(", ", $this->getSkills()) . ".";
}
}
1 Answer
Juthawong Naisanguansee
Full Stack JavaScript Techdegree Graduate 80,724 PointsHi Tonderay ,
This one is a bit confusing for me too. Your code is working , It turn out just a typo error, No need for dot at the end
<?php
//add new child class here
class Developer extends User{
protected $skills;
public function getSkills(){
return $this->skills;
}
public function setSkills($array){
$this->skills = $array;
}
public function displayUserSkills(){
return $this->name . " has the following skills: " . implode(", ", $this->getSkills());
}
}