<?php
namespace Property;

require_once 'Object.php';
require_once 'IKitchen.php';
require_once 'IDoor.php';
require_once 'IWindow.php';
use \Main\Object;	

class Kitchen extends Object implements IKitchen
{
	// Attributes
	private $_door;
	private $_windows;
	
	// Constructor
	// As with the House class, this is a bad approach
	// For testing we want to be able to provide
	// fake Doors and Windows
	/*
	public function __construct()
	{
		$this->_door = new Door();
		$this->_windows = [
								new Window(),
								new Window()
						];
	}
	*/
	public function __construct(IDoor $door, array $windows)
	{
		$this->_door = $door;
		$this->_windows = $windows;
	}
	
	// Methods for the properties
	// Getters and Setters
	
	// Methods
	public function LockDoor()
	{
		$this->_door->Lock();
		return;
	}	

	public function LockWindows()
	{
		foreach($this->_windows as $window)
		{
			if($window instanceof IWindow)
			{
				$window->Lock();
			}
			else 
			{
				throw new \Exception("Object does not implement IWindow");	
			}
		}	
		return;
	}	
}
?>