-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
class Author { | ||
private static $s_id = 0; | ||
private int $id; | ||
private string $firstname; | ||
private string $lastname; | ||
private array $books; | ||
|
||
function __construct(string $firstname, string $lastname, array $books) { | ||
$this->firstname = $firstname; | ||
$this->lastname = $lastname; | ||
$this->books = $books; | ||
$this->id = Author::$s_id++; | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId(int $id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
public function getFirstname(): string | ||
{ | ||
return $this->firstname; | ||
} | ||
|
||
public function setFirstname(string $firstname): void | ||
{ | ||
$this->firstname = $firstname; | ||
} | ||
|
||
public function getLastname(): string | ||
{ | ||
return $this->lastname; | ||
} | ||
|
||
public function setLastname(string $lastname): void | ||
{ | ||
$this->lastname = $lastname; | ||
} | ||
|
||
public function getBooks(): array | ||
{ | ||
return $this->books; | ||
} | ||
|
||
public function setBooks(array $books): void | ||
{ | ||
$this->books = $books; | ||
} | ||
|
||
public function getBookCount(): int { | ||
return count($this->books); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
class Book { | ||
private static $s_id = 0; | ||
private int $id; | ||
private string $name; | ||
private int $year; | ||
|
||
function __construct(string $name, int $year) { | ||
$this->name = $name; | ||
$this->year = $year; | ||
$this->id = Book::$s_id++; | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId(int $id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getYear(): int | ||
{ | ||
return $this->year; | ||
} | ||
|
||
public function setYear(int $year): void | ||
{ | ||
$this->year = $year; | ||
} | ||
|
||
} | ||
|