Junior — Senior
Creating a Book class with main fields and functions
livecode
Task condition
Develop a simple class "Book" with the following attributes:
Properties:
- Name (String) — the title of the book
- Writer (String) — the author
- YearPublished (int) — the year of publication
- Read (bool, default false) — a flag indicating whether the book has been read
Methods:
- Constructor that takes the title, author, and year of publication and initializes the respective properties.
- Function MarkAsRead() that changes the value of the Read property to true.
- Overridden ToString() method that returns a string in the format: "Name Writer (YearPublished)". If the book has already been read, add the suffix " - Read" to the string.