Practice
Book Class Catalogue Card
MEDIUMObject-Oriented Programming10 marks
Declare class Book with private attributes Title, Author and Year. Write the constructor NEW and getter methods. Procedure PrintBook(Item) must output <Title> by <Author> (<Year>).
The test harness reads one book and calls PrintBook.
Input: Title, author, year. Output: One formatted line.
Example:
Input: 1984
George Orwell
1949
Output: 1984 by George Orwell (1949)
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Classic title
Inputs: 1984, George Orwell, 1949
Expected: 1984 by George Orwell (1949)
Test 2: Another book
Inputs: Kindred, Octavia Butler, 1979
Expected: Kindred by Octavia Butler (1979)