Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Object-Oriented PHP Basics Building the Recipe Static

Jason Pham
Jason Pham
8,914 Points

Challenge 4/4

Hey all,

Any help with this challenge please?

Question is:

detailsRoom should accept a single object parameter named $room. The $room object will have the follow methods:

getName: will return a string

getDimensions: will return and array of size integers

Add a return value to the detailsRoom method that displays "name Dimensions: length x width", where name is returned from the room getName method and length x width is returned from the render displayDimensions method.

You will need to call the static method displayDimensions from within the Render class and pass the dimensions from the $room object using the getDimensions method

Final Output Example: Kitchen Dimensions: 12 x 14

I am getting the error: Make sure you are calling the getName method on your $room object.

Thanks

index.php
<?php

class Render {
    public static function displayDimensions($size)
    {
         return $size[0] . ' x ' . $size[1];
    }

    public static function detailsRoom($room)
    {
        return $room->getName . " Dimensions: " . self::displayDimensions($room->getDimensions());
    }
}

?>

3 Answers

You need parentheses () after your getName method

Kaisma Penn-Titley
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Kaisma Penn-Titley
PHP Development Techdegree Graduate 20,151 Points

This worked for me:

<?php

class Render {
 public static function displayDimensions($size) 
{
//  return $size->['length'] . " x " . $size->['width'];
   return $size[0] . " x " . $size[1];
 }   

  public static function detailsRoom($room)
  {
    return $room->getName() . " Dimensions: " . self::displayDimensions($room->getDimensions());
  }
}
?>
Jason Pham
Jason Pham
8,914 Points

HI, thanks I literally figured that out right after I posted the question.