Class for storing book data

PHP Easy classes

Task «Class for storing book data»

Create a class `Book` with private properties: `title` (string), `author` (string), `year` (integer). Implement a constructor that accepts all three parameters. Add getter methods for each property and a `setYear` method that checks that the publication year is not less than 1900 and not greater than the current year (2024), otherwise it outputs the message 'Invalid year' without changing the value. Input data: three strings: title, author, year. Output: title, author, year separated by spaces.

Input Format

Three lines: the first is the title of the book, the second is the author, the third is the year of publication (an integer).

Output Format

String: title, author, year, separated by a space. If the year is invalid, output 'Invalid year'.

Examples

Example 1

INPUT
Война и мир Толстой 1869
OUTPUT
Invalid year

Example 2

INPUT
3 Hello 123abc C++ Pointer
OUTPUT
Invalid year

Example 3

INPUT
1984 Оруэлл 1949
OUTPUT
1984 Оруэлл 1949

Example 4

INPUT
1 AEIOU
OUTPUT
main.php