Book Class Design And Implement A C++ Class Which Represents ✓ Solved

Book Class Design and implement a C++ class which represents a Book, and use this class in a main program which reads in information for multiple books from a data file and outputs them in a nice format to display what books are available for purchase

Design a C++ class called Book that includes member variables for the title, author's first and last names, format (Hardcover, Paperback, Ebook, Audiobook), publishing date, and price. The class should provide at least one constructor, a Display function that shows the book information formatted over no more than two output lines, and getter and setter functions for each data member.

The main program must open a data file, read each line containing book information, create a Book object from this data, display the book details, and repeat until the end of the file. Each step should be a single line of code or a function call. Additionally, implement extra features such as outputting only books priced under $25 and allowing user input of an author's name to filter and display books by that author.

Ensure your code includes proper comments, adheres to good programming style, and is properly indented. Submit the source files, including the main program (MainBook.cpp) and the class definitions (Book.h and Book.cpp), organized within the correct project folder structure as a zipped archive. The teacher will compile and run your code to evaluate correctness, output, and style.

Paper For Above Instructions

The task involves creating a comprehensive C++ programming solution centered around developing a Book class that encapsulates all relevant information about a book and a main program that utilizes this class to process a data file of multiple books. The goal is to demonstrate proficiency in object-oriented programming, file I/O, and user interaction within C++.

Designing the Book Class

At the core, the Book class will include private data members: title, authorFirstName, authorLastName, format, publishDate, and price. The class will feature constructor(s) to initialize these members, a Display method for formatted output, and getter and setter methods for each member to facilitate data access and modification.

The constructor(s) should allow setting all properties during object creation, with default constructors as necessary. The Display method must format book information over a maximum of two lines for clarity and aesthetic appeal, including details like title, author, format, publication date, and price, perhaps aligned for readability.

The getter methods return the current value of the data members (e.g., getTitle(), getAuthorFirstName()), while the setter methods update these values based on input parameters.

File Input and Processing

The main program opens a data file containing multiple lines, each representing a book with its data separated by delimiters (e.g., commas). For each line, the program reads the data, constructs a Book object, and calls its Display method to output details. This process repeats until reaching the end of the file.

Implementation should be concise: each file operation and processing step should be a single line of code or a function call. Comment your code thoroughly to explain key steps and decision points.

Additional Features

  • Output only those books costing less than $25.
  • Prompt the user to input an author's name, then display only books written by that author.

Program Submission and Style

All source code must contain comments indicating purpose, author, date, and any other relevant notes. Maintain clear indentation and descriptive variable naming. Submit a zipped archive of your project folder, including all source files and a proper directory structure, for grading.

The instructor will compile and test the program, and grading will consider correct output, program functionality, and coding style.

References

  • Effective C++: 55 Specific Ways to Improve Your Programs and Designs by Scott Meyers
  • Programming Principles and Practice Using C++ by Bjarne Stroustrup
  • Object-Oriented Programming in C++ by Robert Lafore
  • File Input/Output in C++ by B. S. Gottfried
  • Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin
  • Introduction to Programming in C++ by Y. Daniel Liang
  • Design Patterns: Elements of Reusable Object-Oriented Software by Gamma, Helm, Johnson, Vlissides
  • The C++ Programming Language by Bjarne Stroustrup
  • Data Structures and Algorithm Analysis in C++ by Mark Allen Weiss
  • Standard C++ Library Documentation at cppreference.com