Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Write a function readBooks that populates an array of Book objects with the title and author data found in the file books.txt. This function

c++

Write a function readBooks that populates an array of Book objects with the title and author data found in the file books.txt. This function should: Accept four input arguments in this order: string: the name of the file to be read array of Book objects: books data int: the number of Book objects currently stored in the array of Book objects int: capacity of the library system [assume a max of 200 books] Use ifstream, split(), and getline to read and parse data from the file. For each line in the file: instantiate a Book object, fill in the author and title data members, and append the object to your array of Book objects. Return the total number of books in the system, as an integer. If the file cannot be opened, return 1 Important: when testing your readBooks function, make sure it supports multiple calls in a row. For example, you should be able to call the function to read the file books1.txt , and then call the function again to read the file book2.txt. The result should be an array of Book objects, with the books from the first file, followed by the books from the second file.

books.txt

Douglas Adams,The Hitchhiker's Guide To The Galaxy Richard Adams,Watership Down Mitch Albom,The Five People You Meet in Heaven Laurie Halse Anderson,Speak Maya Angelou,I Know Why the Caged Bird Sings Jay Asher,Thirteen Reasons Why Isaac Asimov,Foundation Series Ann Brashares,The Sisterhood of the Travelling Pants Libba Bray,A Great and Terrible Beauty Dan Brown,The Da Vinci Code Meg Cabot,The Princess Diaries Orson Scott Card,Ender's Game Tom Clancy,The Hunt for Red October Suzanne Collins,The Hunger Games F. Scott Fitzgerald,The Great Gatsby John Flanagan,Ranger's Apprentice Series Cornelia Funke,Inkheart William Gibson,Neuromancer William Golding,Lord of the Flies William Goldman,The Princess Bride James Gurney,Dinotopia: A Land Apart from Time Will Hobbs,Far North Alice Hoffman,Practical Magic Aldous Huxley,Brave New World Guy Gavriel Kay,The Summer Tree Daniel Keyes,Flowers For Algernon Patrice Kindl,Owl in Love Masashi Kishimoto,Naruto Tite Kubo,Bleach (graphic novel) Elizabeth Laird,Kiss the Dust Harper Lee,To Kill a Mockingbird C S Lewis,The Lion the Witch and the Wardrobe Robert Ludlum,The Bourne Series Yann Martel,Life of Pi Lurlene McDaniel,Breathless Stephenie Meyer,Twilight Series Garth Nix,Sabriel George Orwell,Nineteen Eighty-Four (1984) Christopher Paolini,Eragon Gary Paulsen,Hatchet Jodi Picoult,My Sister's Keeper Philip Pullman,The Golden Compass J.K. Rowling,Harry Potter Series Louis Sachar,Holes Shueisha,Shonen Jump Series Neil Shusterman,The Shadow Club Jeff Smith,Bone Series Art Spiegelman,Maus: A Survivor's Tale Amy Tan,The Joy Luck Club J R R Tolkien,The Lord of the Rings

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions