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 trialDipika Purohit
Courses Plus Student 20,955 PointsImplementing interfaces
I didnt understant this question can some please help me with its codeing
Write a class named "Treehouse" that sets and retrieves the correct details by uses the following Interface: interface Learnable { public function setTitle($title); public function setContentType($type = 'video'); public function setLocation($loc);
public function getTitle();
public function getContentType();
public function getLocation();
}
<?php
class Treehouse implements Iterator,countable
{
public function setTitle($title);
public function setContentType($type = 'video');
public function setLocation($loc);
public function getTitle();
public function getContentType();
public function getLocation();
}
2 Answers
Daniel Marin
8,021 PointsHi Dipika Purohit You need to implement Learnable which means the class Tree needs to abide to the Learnable contract Here's how you can do it:
<?php
class Treehouse implements Learnable {
private $title;
private $type;
private $loc;
public function setTitle($title) {
$this->title = $title;
}
public function setContentType($type = 'video') {
$this->type = $type;
}
public function setLocation($loc) {
$this->loc = $loc;
}
public function getTitle() {
return $this->title;
}
public function getContentType() {
return $this->type;
}
public function getLocation() {
return $this->loc;
}
}
Glen Rose
7,108 Pointsthanks....
Dipika Purohit
Courses Plus Student 20,955 PointsDipika Purohit
Courses Plus Student 20,955 Pointsthanx Daniel Marin