007-001-009
Class Definition: Book Management
Easy
Problem Description
Class Definition: Book Management
In this problem, you will define a Book class that stores book information in fields and displays it via a method.
Learning Objective: Understand the basic structure of a class (fields and methods)
Overview
Define a Book class to represent a book. Learn that classes have "fields that hold data" and "methods that define behavior".
Specifications
Book Class
- Fields:
String title(book title)String author(author name)int pages(number of pages)
- Methods:
void displayInfo(): Display book information in format "Title: [title], Author: [author], Pages: [pages]"
Notes
- Fields should be directly assignable from outside after instance creation
- The displayInfo() method must exactly reproduce the specified format
- Tests will verify the Book class behavior with various book data
Output Format Example
Title: Clean Code, Author: Robert Martin, Pages: 464
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up