Question: Need C++ code. Need to write the functions in library.cpp. Source.cpp file /* Bonus: Keep array sorted and use binary search! Bonus: getline */ #include

Need C++ code. Need to write the functions in library.cpp. Source.cpp fileNeed C++ code. Need to write the functions in library.cpp. /* Bonus: Keep array sorted and use binary search! Bonus: getline */

#include #include #include "library.h" using namespace std; int displayMainMenu(); int main() {

Book inventory[MAX_BOOKS]; int currID = 0; int numBooks = 0; string fileName

= "libraryInventory.txt"; if (!loadBooks(fileName, inventory, numBooks, currID)) { cout system("PAUSE"); } enum

class MainMenu { add = 1, remove, checkOut, checkIn, save, quit, NA

}; MainMenu choice = MainMenu::NA; while (choice != MainMenu::quit) { system("CLS"); choice

Source.cpp file

/*

Bonus: Keep array sorted and use binary search!

Bonus: getline

*/

#include

#include

#include "library.h"

using namespace std;

int displayMainMenu();

int main()

{

Book inventory[MAX_BOOKS];

int currID = 0;

int numBooks = 0;

string fileName = "libraryInventory.txt";

if (!loadBooks(fileName, inventory, numBooks, currID))

{

cout

system("PAUSE");

}

enum class MainMenu { add = 1, remove, checkOut, checkIn, save, quit, NA };

MainMenu choice = MainMenu::NA;

while (choice != MainMenu::quit)

{

system("CLS");

choice = (MainMenu)displayMainMenu();

system("CLS");

switch (choice)

{

case MainMenu::add:

{

addNewBook(currID, inventory, numBooks);

break;

}

case MainMenu::remove:

removeBook(inventory, numBooks);

break;

case MainMenu::checkOut:

checkOut(inventory, numBooks);

break;

case MainMenu::checkIn:

checkIn(inventory, numBooks);

break;

case MainMenu::quit:

cout

case MainMenu::save:

if (saveBooks(fileName, inventory, numBooks, currID))

{

cout

}

else

{

cout

}

system("PAUSE");

break;

default:

cout

system("PAUSE");

break;

}

}

return 0;

}

int displayMainMenu()

{

int choice = 0;

while (choice 6)

{

cout

cout

cout

cout

cout

cout

cout

cout

cin >> choice;

}

return (choice);

}

Library.h file

#ifndef LIBRARY_H

#define LIBRARY_H

#include

struct Book {

std::string author = " ";

std::string title = " ";

bool checkedOut = false;

int ID = -1;

};

const int MAX_BOOKS = 1'000;

bool checkIn(const int ID, Book inventory[], const int numBooks);

void checkIn(Book inventory[], const int numBooks);

bool checkOut(const int ID, Book inventory[], const int numBooks);

void checkOut(Book inventory[], const int numBooks);

bool addBook

(

const std::string& author,

const std::string& title,

const int ID,

Book inventory[],

int& numBooks);

void addNewBook(int& currID, Book inventory[], int& numBooks);

void removeBook(Book inventory[], int& numBooks);

bool removeBook(const int ID, Book inventory[], int& numBooks);

bool loadBooks(const std::string& fileName, Book inventory[], int& numBooks, int& lastID);

bool saveBooks(const std::string& fileName, const Book inventory[], const int numBooks, const int lastID);

//helper functions;

//returns index of book in inventory[]

int findBook(const int ID, const Book inventory[], const int numBooks);

#endif // !LIBRARY_H

library.cpp file (this is the file I want to write code in)

#include

#include

#include "library.h"

using namespace std;

bool checkIn(const int ID, Book inventory[], const int numBooks)

{

return true;

}

void checkIn(Book inventory[], const int numBooks)

{

}

bool checkOut(const int ID, Book inventory[], const int numBooks)

{

return true;

}

void checkOut(Book inventory[], const int numBooks)

{

}

bool addBook(const std::string & author, const std::string & title, const int ID, Book inventory[], int & numBooks)

{

return true ;

}

void addNewBook(int & currID, Book inventory[], int & numBooks)

{

}

void removeBook(Book inventory[], int & numBooks)

{

}

bool removeBook(const int ID, Book inventory[], int & numBooks)

{

return true;

}

bool loadBooks(const std::string & fileName, Book inventory[], int & numBooks, int & lastID)

{

return true;

}

bool saveBooks(const std::string & fileName, const Book inventory[], const int numBooks, const int lastID)

{

return true;

}

int findBook(const int ID, const Book inventory[], const int numBooks)

{

return 0;

}

1. Add a book to inventory 2. Remove a book from inventory 3. Check out a book 4. Check in a book 5. Save Inenvtory 6. Save Inenvtory& Quit Please make a selection(1-6)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!