<?php
class Booklibrary {
private $bookName = '';
private $bookAuthor = '';
const BR = '<br/>';
public function __construct($name = '', $author = '') {
$this->bookName = $name;
$this->bookAuthor = $author;
}
public function getNameAndAuthor() {
return $this->bookName . ' - ' . $this->bookAuthor . self::BR;
}
}
class BooklibraryFactory {
public static function create($name, $author) {
return new Booklibrary($name, $author);
}
}
$bookOne = BooklibraryFactory::create('Shiv Khera', 'You can win');
$bookTwo = BooklibraryFactory::create('Norman Vincent Peale', 'The Power Of Positive Thinking.');
echo $bookOne->getNameAndAuthor();
echo $bookTwo->getNameAndAuthor();
No comments:
Post a Comment